Class DBMapping
java.lang.Object
org.nuiton.topia.persistence.util.DBMapping
Une classe qui permet d'obtenir les mapping de noms entre les entités et les objets de la base.
On retrouve aussi ici des méthodes utils pour executer du code sql sur la base (notamment la gestion des séquences).
- Author:
- tchemit <chemit@codelutin.com>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final org.apache.commons.logging.Loglogprotected static final Stringprotected Stringprotected static final Stringprotected static final Stringprotected Map<String,Class<? extends TopiaEntity>> protected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcheckSequence(Class<? extends TopiaEntity> entityClass, String propertyName) protected StringcheckSequence(String sequenceKey) voidclose()voidcreateSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) voidcreateSequence(String sequenceKey, TopiaContext ctxt) voidcreateSequence(String sequenceKey, TopiaContext ctxt, boolean check) voidcreateSequences(TopiaContext ctxt) protected voiddoSQLWork(TopiaContext ctxt, String sql) booleanexistSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) booleanexistSequence(String sequenceKey, TopiaContext ctxt) booleanexistSequence(String sequenceKey, TopiaContext ctxt, boolean check) protected voidfinalize()protected BigIntegergetBigInteger(TopiaContext ctxt, String sql, BigInteger defaultSize) protected abstract Class<? extends TopiaEntity>getContractClass(Class<? extends TopiaEntity> entityClass) getCurrentValueFromSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) getCurrentValueFromSequence(String sequenceKey, TopiaContext ctxt) getCurrentValueFromSequence(String sequenceKey, TopiaContext ctxt, boolean check) protected StringgetDBProperty(Class<? extends TopiaEntity> entityClass, String property) protected StringgetDBTable(Class<? extends TopiaEntity> entityClass) getNextValueFromSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) getNextValueFromSequence(String sequenceKey, TopiaContext ctxt) getNextValueFromSequence(String sequenceKey, TopiaContext ctxt, boolean check) protected StringgetSequencePropertyName(String sequenceKey) protected StringgetSequenceSQL(String pattern, Class<? extends TopiaEntity> entityClass, String propertyName) protected StringgetSequenceSQL(String pattern, String sequenceKey) voidinit(TopiaContext ctxt, boolean doCreate, boolean doUpdate) protected voidinitMapping(Properties props) voidupdateSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) voidupdateSequence(String sequenceKey, TopiaContext ctxt) voidupdateSequence(String sequenceKey, TopiaContext ctxt, boolean check) voidupdateSequences(TopiaContext ctxt)
-
Field Details
-
log
protected static final org.apache.commons.logging.Log loglog -
CLASS_PATTERN
- See Also:
-
DBNAME_ATTRIBUTE_PATTERN
- See Also:
-
SEQUENCE_ATTRIBUTE_PATTERN
- See Also:
-
CREATE_SEQUENCE_FORMAT
- See Also:
-
UPDATE_SEQUENCE_FORMAT
- See Also:
-
CURRENT_VALUE_SEQUENCE_FORMAT
- See Also:
-
NEXT_VALUE_SEQUENCE_FORMAT
- See Also:
-
SCHEMA_FORMAT
- See Also:
-
DOT
- See Also:
-
mappingBeanToDb
-
sequences
-
schema
-
-
Constructor Details
-
DBMapping
- Throws:
IOException
-
-
Method Details
-
getContractClass
protected abstract Class<? extends TopiaEntity> getContractClass(Class<? extends TopiaEntity> entityClass) throws TopiaException - Throws:
TopiaException
-
init
- Throws:
TopiaException
-
createSequences
- Throws:
TopiaException
-
updateSequences
- Throws:
TopiaException
-
existSequence
- Throws:
TopiaException
-
createSequence
- Throws:
TopiaException
-
updateSequence
- Throws:
TopiaException
-
getCurrentValueFromSequence
public BigInteger getCurrentValueFromSequence(String sequenceKey, TopiaContext ctxt) throws TopiaException - Throws:
TopiaException
-
getNextValueFromSequence
public BigInteger getNextValueFromSequence(String sequenceKey, TopiaContext ctxt) throws TopiaException - Throws:
TopiaException
-
existSequence
public boolean existSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) throws TopiaException - Throws:
TopiaException
-
createSequence
public void createSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) throws TopiaException - Throws:
TopiaException
-
updateSequence
public void updateSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) throws TopiaException - Throws:
TopiaException
-
getCurrentValueFromSequence
public BigInteger getCurrentValueFromSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) throws TopiaException - Throws:
TopiaException
-
getNextValueFromSequence
public BigInteger getNextValueFromSequence(Class<? extends TopiaEntity> entityClass, String propertyName, TopiaContext ctxt) throws TopiaException - Throws:
TopiaException
-
getSequenceKeysIterator
-
existSequence
public boolean existSequence(String sequenceKey, TopiaContext ctxt, boolean check) throws TopiaException - Throws:
TopiaException
-
createSequence
public void createSequence(String sequenceKey, TopiaContext ctxt, boolean check) throws TopiaException - Throws:
TopiaException
-
updateSequence
public void updateSequence(String sequenceKey, TopiaContext ctxt, boolean check) throws TopiaException - Throws:
TopiaException
-
getCurrentValueFromSequence
public BigInteger getCurrentValueFromSequence(String sequenceKey, TopiaContext ctxt, boolean check) throws TopiaException - Throws:
TopiaException
-
getNextValueFromSequence
public BigInteger getNextValueFromSequence(String sequenceKey, TopiaContext ctxt, boolean check) throws TopiaException - Throws:
TopiaException
-
getDBProperty
protected String getDBProperty(Class<? extends TopiaEntity> entityClass, String property) throws TopiaException - Parameters:
entityClass- the seek entity classproperty- the name of the property to translate- Returns:
- the DB name for the given property
- Throws:
TopiaException- if any db pb
-
getDBTable
- Parameters:
entityClass- the seek entity class- Returns:
- the DB name for the given property
- Throws:
TopiaException- if any db pb
-
getSequenceSQL
protected String getSequenceSQL(String pattern, Class<? extends TopiaEntity> entityClass, String propertyName) throws TopiaException - Throws:
TopiaException
-
getSequenceSQL
- Throws:
TopiaException
-
getBigInteger
protected BigInteger getBigInteger(TopiaContext ctxt, String sql, BigInteger defaultSize) throws TopiaException - Throws:
TopiaException
-
doSQLWork
- Throws:
TopiaException
-
getSequencePropertyName
-
checkSequence
protected String checkSequence(Class<? extends TopiaEntity> entityClass, String propertyName) throws IllegalArgumentException, TopiaException -
checkSequence
-
initMapping
- Throws:
IOException
-
finalize
-
close
public void close()
-