org.nuiton.topia.persistence.util
Class DBMapping
java.lang.Object
org.nuiton.topia.persistence.util.DBMapping
public abstract class DBMapping
- extends Object
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
|
Method Summary |
protected String |
checkSequence(Class<? extends TopiaEntity> entityClass,
String propertyName)
|
protected String |
checkSequence(String sequenceKey)
|
void |
close()
|
void |
createSequence(Class<? extends TopiaEntity> entityClass,
String propertyName,
TopiaContext ctxt)
|
void |
createSequence(String sequenceKey,
TopiaContext ctxt)
|
void |
createSequence(String sequenceKey,
TopiaContext ctxt,
boolean check)
|
void |
createSequences(TopiaContext ctxt)
|
protected void |
doSQLWork(TopiaContext ctxt,
String sql)
|
boolean |
existSequence(Class<? extends TopiaEntity> entityClass,
String propertyName,
TopiaContext ctxt)
|
boolean |
existSequence(String sequenceKey,
TopiaContext ctxt)
|
boolean |
existSequence(String sequenceKey,
TopiaContext ctxt,
boolean check)
|
protected void |
finalize()
|
protected BigInteger |
getBigInteger(TopiaContext ctxt,
String sql,
BigInteger defaultSize)
|
protected abstract Class<? extends TopiaEntity> |
getContractClass(Class<? extends TopiaEntity> entityClass)
|
BigInteger |
getCurrentValueFromSequence(Class<? extends TopiaEntity> entityClass,
String propertyName,
TopiaContext ctxt)
|
BigInteger |
getCurrentValueFromSequence(String sequenceKey,
TopiaContext ctxt)
|
BigInteger |
getCurrentValueFromSequence(String sequenceKey,
TopiaContext ctxt,
boolean check)
|
protected String |
getDBProperty(Class<? extends TopiaEntity> entityClass,
String property)
|
protected String |
getDBTable(Class<? extends TopiaEntity> entityClass)
|
BigInteger |
getNextValueFromSequence(Class<? extends TopiaEntity> entityClass,
String propertyName,
TopiaContext ctxt)
|
BigInteger |
getNextValueFromSequence(String sequenceKey,
TopiaContext ctxt)
|
BigInteger |
getNextValueFromSequence(String sequenceKey,
TopiaContext ctxt,
boolean check)
|
Iterator<String> |
getSequenceKeysIterator()
|
protected String |
getSequencePropertyName(String sequenceKey)
|
protected String |
getSequenceSQL(String pattern,
Class<? extends TopiaEntity> entityClass,
String propertyName)
|
protected String |
getSequenceSQL(String pattern,
String sequenceKey)
|
void |
init(TopiaContext ctxt,
boolean doCreate,
boolean doUpdate)
|
protected void |
initMapping(Properties props)
|
void |
updateSequence(Class<? extends TopiaEntity> entityClass,
String propertyName,
TopiaContext ctxt)
|
void |
updateSequence(String sequenceKey,
TopiaContext ctxt)
|
void |
updateSequence(String sequenceKey,
TopiaContext ctxt,
boolean check)
|
void |
updateSequences(TopiaContext ctxt)
|
log
protected static final org.apache.commons.logging.Log log
- log
CLASS_PATTERN
protected static final String CLASS_PATTERN
- See Also:
- Constant Field Values
DBNAME_ATTRIBUTE_PATTERN
protected static final String DBNAME_ATTRIBUTE_PATTERN
- See Also:
- Constant Field Values
SEQUENCE_ATTRIBUTE_PATTERN
protected static final String SEQUENCE_ATTRIBUTE_PATTERN
- See Also:
- Constant Field Values
CREATE_SEQUENCE_FORMAT
protected static final String CREATE_SEQUENCE_FORMAT
- See Also:
- Constant Field Values
UPDATE_SEQUENCE_FORMAT
protected static final String UPDATE_SEQUENCE_FORMAT
- See Also:
- Constant Field Values
CURRENT_VALUE_SEQUENCE_FORMAT
protected static final String CURRENT_VALUE_SEQUENCE_FORMAT
- See Also:
- Constant Field Values
NEXT_VALUE_SEQUENCE_FORMAT
protected static final String NEXT_VALUE_SEQUENCE_FORMAT
- See Also:
- Constant Field Values
SCHEMA_FORMAT
protected static final String SCHEMA_FORMAT
- See Also:
- Constant Field Values
DOT
protected static final String DOT
- See Also:
- Constant Field Values
mappingBeanToDb
protected Map<String,String> mappingBeanToDb
sequences
protected Map<String,Class<? extends TopiaEntity>> sequences
schema
protected String schema
DBMapping
public DBMapping(String propertyFile,
String path)
throws IOException
- Throws:
IOException
getContractClass
protected abstract Class<? extends TopiaEntity> getContractClass(Class<? extends TopiaEntity> entityClass)
throws TopiaException
- Throws:
TopiaException
init
public void init(TopiaContext ctxt,
boolean doCreate,
boolean doUpdate)
throws TopiaException
- Throws:
TopiaException
createSequences
public void createSequences(TopiaContext ctxt)
throws TopiaException
- Throws:
TopiaException
updateSequences
public void updateSequences(TopiaContext ctxt)
throws TopiaException
- Throws:
TopiaException
existSequence
public boolean existSequence(String sequenceKey,
TopiaContext ctxt)
throws TopiaException
- Throws:
TopiaException
createSequence
public void createSequence(String sequenceKey,
TopiaContext ctxt)
throws TopiaException
- Throws:
TopiaException
updateSequence
public void updateSequence(String sequenceKey,
TopiaContext ctxt)
throws TopiaException
- 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
public Iterator<String> 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
protected String getDBTable(Class<? extends TopiaEntity> entityClass)
throws TopiaException
- 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
protected String getSequenceSQL(String pattern,
String sequenceKey)
throws TopiaException
- Throws:
TopiaException
getBigInteger
protected BigInteger getBigInteger(TopiaContext ctxt,
String sql,
BigInteger defaultSize)
throws TopiaException
- Throws:
TopiaException
doSQLWork
protected void doSQLWork(TopiaContext ctxt,
String sql)
throws TopiaException
- Throws:
TopiaException
getSequencePropertyName
protected String getSequencePropertyName(String sequenceKey)
checkSequence
protected String checkSequence(Class<? extends TopiaEntity> entityClass,
String propertyName)
throws IllegalArgumentException,
TopiaException
- Throws:
IllegalArgumentException
TopiaException
checkSequence
protected String checkSequence(String sequenceKey)
throws IllegalArgumentException,
TopiaException
- Throws:
IllegalArgumentException
TopiaException
initMapping
protected void initMapping(Properties props)
throws IOException
- Throws:
IOException
finalize
protected void finalize()
throws Throwable
- Overrides:
finalize in class Object
- Throws:
Throwable
close
public void close()
Copyright © 2004-2012 CodeLutin. All Rights Reserved.