public class OrmHandler extends Object implements OrmHandlerProvider
| Constructor and Description |
|---|
OrmHandler()
The constructor
|
OrmHandler(Class<UJO>... databaseModels)
The constructor with a database metamodel initialization.
|
OrmHandler(Class<UJO> databaseModel)
The constructor with a database metamodel initialization.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addColumnModel(MetaRelation2Many column)
Map a key to the table
|
void |
addProcedureModel(MetaProcedure metaProcedure)
Map a key to the table
|
void |
addTableModel(MetaTable metaTable)
Map a key to the table
|
<UJO extends OrmUjo> |
alias(Class<UJO> entity,
String alias)
Deprecated.
|
void |
config(MetaParams params)
Save the ORM parameters.
|
void |
config(MetaRoot config)
Save the alternative ORM configuration including parameters (if the parameters are not null).
|
boolean |
config(String url)
Load parameters from an external XML file.
|
boolean |
config(URL url,
boolean throwsException)
Load parameters from an external XML file.
|
Session |
createSession()
Create new session
|
<T extends Annotation> |
findAnnotation(Key<?,?> key,
Class<T> annotation)
Deprecated.
Uset the
UjoManager.findAnnotation(org.ujorm.Key, java.lang.Class) rather |
<T extends MetaRelation2Many> |
findColumnModel(Key compositeKey)
Find a Relation/Column model of the parameter key.
|
<T extends MetaRelation2Many> |
findColumnModel(Key compositeKey,
boolean throwException)
Find a Relation/Column model of the parameter key.
|
MetaProcedure |
findProcedureModel(Class<? extends DbProcedure> procedureClass)
Find a procedure model by the procedureClass.
|
List<Key> |
findPropertiesByType(Class type)
Find all persistent keys with the required type or subtype.
|
MetaTable |
findTableModel(Class<? extends OrmUjo> dbClass)
Find a table model by the dbCl111ass.
|
MetaTable |
findTableModel(Class<? extends OrmUjo> dbClass,
boolean throwException)
Find a table model by the dbClass.
|
TableWrapper |
findTableModel(Key key)
Find a base table model with a correct alias by the last direct key.
|
String |
getConfig()
Returns a final meta-model in the XML format
|
MetaRoot |
getDatabaseModel()
Returns database model
|
List<MetaDatabase> |
getDatabases()
Returns all database
|
Session |
getDefaultSession()
Get a default Session of the OrmHandler.
|
OrmHandler |
getOrmHandler()
Returns the same instance
|
MetaParams |
getParameters()
Returns parameters
|
Session |
getSession()
Deprecated.
Method was replaced by the name
getDefaultSession() |
boolean |
isDatabaseLoaded()
Returns true, if a database meta-model is loaded.
|
boolean |
isPersistent(Key key)
Is the parameter a persistent key?
|
boolean |
isReadOnly()
Do the handler have a read-only state?
|
<UJO extends OrmUjo> |
loadDatabase(Class<UJO>... databaseModel)
Load a meta-data, lock it and create database tables.
|
<UJO extends OrmUjo> |
loadDatabase(Class<UJO> databaseModel)
Load a meta-data, lock it and create database tables.
|
<UJO extends OrmUjo> |
tableOf(Class<UJO> entity)
Create a new instance of the class
AliasTable |
<UJO extends OrmUjo> |
tableOf(Class<UJO> entity,
String alias)
Create a new instance of the class
AliasTable |
public OrmHandler()
public OrmHandler(Class<UJO> databaseModel)
public OrmHandler(Class<UJO>... databaseModels)
public Session getDefaultSession()
createSession() rather.createSession()public Session getSession()
getDefaultSession()createSession() rather.createSession()public Session createSession()
public boolean config(String url) throws IllegalUjormException
IllegalUjormExceptionpublic void config(MetaParams params) throws IllegalArgumentException
IllegalArgumentExceptionpublic void config(MetaRoot config) throws IllegalArgumentException
IllegalArgumentExceptionpublic boolean config(URL url, boolean throwsException) throws IllegalUjormException
IllegalUjormExceptionpublic boolean isPersistent(Key key)
public final <UJO extends OrmUjo> void loadDatabase(Class<UJO> databaseModel)
public final <UJO extends OrmUjo> void loadDatabase(Class<UJO>... databaseModel)
public boolean isReadOnly()
public MetaRoot getDatabaseModel()
public void addProcedureModel(MetaProcedure metaProcedure)
public void addTableModel(MetaTable metaTable)
public void addColumnModel(MetaRelation2Many column)
@Deprecated public <T extends Annotation> T findAnnotation(Key<?,?> key, Class<T> annotation)
UjoManager.findAnnotation(org.ujorm.Key, java.lang.Class) ratherkey - The key must be a public static final field of the related Ujo class.annotation - Annotation typenull valuepublic final <T extends MetaRelation2Many> T findColumnModel(Key compositeKey)
MetaColumn.compositeKey - Parameter can be type of Key of CompositeKey (direct or indirect);MetaColumn for database column
or a related model type of MetaRelation2Many
or the NULL if no model was found.public <T extends MetaRelation2Many> T findColumnModel(Key compositeKey, boolean throwException) throws IllegalUjormException
MetaColumn.compositeKey - Parameter can be type of CompositeKey (direct or indirect);throwException - Throw the IllegalArgument exception of no Model was not foundMetaColumn for database column
or a related model type of MetaRelation2Many
or the NULL if no model was found.IllegalUjormExceptionpublic final TableWrapper findTableModel(Key key) throws IllegalStateException
IllegalStateExceptionpublic final MetaTable findTableModel(Class<? extends OrmUjo> dbClass) throws IllegalStateException
IllegalStateExceptionpublic MetaTable findTableModel(Class<? extends OrmUjo> dbClass, boolean throwException) throws IllegalUjormException
throwException - Throw the IllegalArgument exception of no Model was not foundIllegalUjormExceptionpublic MetaProcedure findProcedureModel(Class<? extends DbProcedure> procedureClass) throws IllegalUjormException
IllegalUjormExceptionpublic MetaParams getParameters()
public boolean isDatabaseLoaded()
public List<MetaDatabase> getDatabases()
public List<Key> findPropertiesByType(Class type)
type - The parameter value Object.clas returns all persistent keys.public String getConfig()
public OrmHandler getOrmHandler()
getOrmHandler in interface OrmHandlerProviderpublic <UJO extends OrmUjo> AliasTable<UJO> tableOf(Class<UJO> entity, String alias)
AliasTablepublic <UJO extends OrmUjo> AliasTable<UJO> tableOf(Class<UJO> entity)
AliasTable@Deprecated public <UJO extends OrmUjo> AliasTable<UJO> alias(Class<UJO> entity, String alias)
AliasTable.
Use the new method tableOf(java.lang.Class, java.lang.String) ratherCopyright 2013, Pavel Ponec