jodd.db.orm
Class DbOrmManager

java.lang.Object
  extended by jodd.db.orm.DbOrmManager

public class DbOrmManager
extends java.lang.Object

Global DB-ORM mapping definitions, prefixes and cache.

Mapping definitions are used only by a result set mapper (such as ResultSetMapper to lookup for an entity from table name. Table names are read from result-set meta data, for example. Moreover, it is not needed to use mappings at all: in that case just provide entity types during result set to objects conversion.


Field Summary
protected  java.lang.String columnAliasSeparator
           
protected  boolean columnNameUppercase
           
protected  ColumnAliasType defaultColumnAliasType
           
protected  java.util.Map<java.lang.Class,DbEntityDescriptor> descriptors
           
protected  java.util.Map<java.lang.String,DbEntityDescriptor> entityNames
           
protected  JoinHintResolver hintResolver
           
protected  java.lang.String[] primitiveEntitiesPrefixes
           
protected  java.lang.String schemaName
           
protected  java.lang.String tableNamePrefix
           
protected  java.util.Map<java.lang.String,DbEntityDescriptor> tableNames
           
protected  java.lang.String tableNameSuffix
           
protected  boolean tableNameUppercase
           
 
Constructor Summary
protected DbOrmManager()
           
 
Method Summary
protected  DbEntityDescriptor createDbEntityDescriptor(java.lang.Class type)
          Creates DbEntityDescriptor.
 java.lang.String getColumnAliasSeparator()
          Returns value for separator for column aliases that divides table reference and column name.
 ColumnAliasType getDefaultColumnAliasType()
           
 JoinHintResolver getHintResolver()
           
static DbOrmManager getInstance()
          Returns current DB-ORM instance.
 java.lang.String[] getPrimitiveEntitiesPrefixes()
           
 java.lang.String getSchemaName()
          Returns default schema name.
 java.lang.String getTableNamePrefix()
          Returns current table prefix.
 java.lang.String getTableNameSuffix()
          Returns table name suffix.
 int getTotalNames()
          Returns total number of registered entity names.
 int getTotalTableNames()
          Returns total number of registered table names.
 int getTotalTypes()
          Returns total number of registered types.
 boolean isColumnNameUppercase()
          Returns true if column names are uppercase.
 boolean isRegistered(java.lang.Class type)
          Returns true if type is registered withing manager.
 boolean isTableNameUppercase()
          Returns true if table names are uppercase.
 DbEntityDescriptor lookupName(java.lang.String typeName)
          Lookups for DbEntityDescriptor that was registered with this manager.
 DbEntityDescriptor lookupTableName(java.lang.String typeName)
          Lookups for DbEntityDescriptor that was registered with this manager.
 DbEntityDescriptor lookupType(java.lang.Class type)
          Lookups DbEntityDescriptor for some type and registers the type if is new.
 DbEntityDescriptor registerEntity(java.lang.Class type)
          Registers entity.
 DbEntityDescriptor registerEntity(java.lang.Class type, boolean force)
          Registers entity.
 DbEntityDescriptor registerType(java.lang.Class type)
          Registers just type and entity names.
 DbEntityDescriptor removeEntity(java.lang.Class type)
          Removes entity.
 void reset()
          Resets the manager and clears descriptors cache.
 void setColumnAliasSeparator(java.lang.String separator)
          Specifies separator for column aliases that divides table reference and column name.
 void setColumnNameUppercase(boolean columnNameUppercase)
          Specifies if column names are in upper case.
 void setDefaultColumnAliasType(ColumnAliasType defaultColumnAliasType)
           
 void setHintResolver(JoinHintResolver hintResolver)
           
static void setInstance(DbOrmManager ormManager)
          Sets new default instance for DB-ORM mapper.
 void setPrimitiveEntitiesPrefixes(java.lang.String... primitiveEntitiesPrefixes)
          Specifies array of class name prefixes that will be mapped directly to column.
 void setSchemaName(java.lang.String schemaName)
          Specifies default schema name.
 void setTableNamePrefix(java.lang.String prefix)
          Specifies default table prefix for all tables.
 void setTableNameSuffix(java.lang.String suffix)
          Specifies default table name suffix.
 void setTableNameUppercase(boolean tableNameUppercase)
          Specifies if table names are in upper case.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableNameUppercase

protected boolean tableNameUppercase

columnNameUppercase

protected boolean columnNameUppercase

tableNamePrefix

protected java.lang.String tableNamePrefix

tableNameSuffix

protected java.lang.String tableNameSuffix

schemaName

protected java.lang.String schemaName

primitiveEntitiesPrefixes

protected java.lang.String[] primitiveEntitiesPrefixes

descriptors

protected java.util.Map<java.lang.Class,DbEntityDescriptor> descriptors

entityNames

protected java.util.Map<java.lang.String,DbEntityDescriptor> entityNames

tableNames

protected java.util.Map<java.lang.String,DbEntityDescriptor> tableNames

columnAliasSeparator

protected java.lang.String columnAliasSeparator

hintResolver

protected JoinHintResolver hintResolver

defaultColumnAliasType

protected ColumnAliasType defaultColumnAliasType
Constructor Detail

DbOrmManager

protected DbOrmManager()
Method Detail

getInstance

public static DbOrmManager getInstance()
Returns current DB-ORM instance.


setInstance

public static void setInstance(DbOrmManager ormManager)
Sets new default instance for DB-ORM mapper.


setTableNameUppercase

public void setTableNameUppercase(boolean tableNameUppercase)
Specifies if table names are in upper case.


isTableNameUppercase

public boolean isTableNameUppercase()
Returns true if table names are uppercase.


setColumnNameUppercase

public void setColumnNameUppercase(boolean columnNameUppercase)
Specifies if column names are in upper case.


isColumnNameUppercase

public boolean isColumnNameUppercase()
Returns true if column names are uppercase.


setTableNamePrefix

public void setTableNamePrefix(java.lang.String prefix)
Specifies default table prefix for all tables. This prefix affect default conversions from bean name to table name and vice-versa when no annotations are used.


getTableNamePrefix

public java.lang.String getTableNamePrefix()
Returns current table prefix.


getTableNameSuffix

public java.lang.String getTableNameSuffix()
Returns table name suffix.


setTableNameSuffix

public void setTableNameSuffix(java.lang.String suffix)
Specifies default table name suffix.


getSchemaName

public java.lang.String getSchemaName()
Returns default schema name.


setSchemaName

public void setSchemaName(java.lang.String schemaName)
Specifies default schema name.


getPrimitiveEntitiesPrefixes

public java.lang.String[] getPrimitiveEntitiesPrefixes()

setPrimitiveEntitiesPrefixes

public void setPrimitiveEntitiesPrefixes(java.lang.String... primitiveEntitiesPrefixes)
Specifies array of class name prefixes that will be mapped directly to column.


lookupType

public DbEntityDescriptor lookupType(java.lang.Class type)
Lookups DbEntityDescriptor for some type and registers the type if is new.

Returns null for core classes from java run-time packages! Some types are not entities, i.e. domain objects. Instead, primitive entities are simply mapped to one column.


isRegistered

public boolean isRegistered(java.lang.Class type)
Returns true if type is registered withing manager.


lookupName

public DbEntityDescriptor lookupName(java.lang.String typeName)
Lookups for DbEntityDescriptor that was registered with this manager. Returns null if name not found.


lookupTableName

public DbEntityDescriptor lookupTableName(java.lang.String typeName)
Lookups for DbEntityDescriptor that was registered with this manager. Returns null if table name not found.


registerType

public DbEntityDescriptor registerType(java.lang.Class type)
Registers just type and entity names. Enough for most usages.


registerEntity

public DbEntityDescriptor registerEntity(java.lang.Class type)
Registers entity. Registers types and table names. Throw exception is type is already registered.


registerEntity

public DbEntityDescriptor registerEntity(java.lang.Class type,
                                         boolean force)
Registers entity. Existing entity will be removed if exist, so no exception will be thrown.


removeEntity

public DbEntityDescriptor removeEntity(java.lang.Class type)
Removes entity.


createDbEntityDescriptor

protected DbEntityDescriptor createDbEntityDescriptor(java.lang.Class type)
Creates DbEntityDescriptor.


getTotalNames

public int getTotalNames()
Returns total number of registered entity names.


getTotalTableNames

public int getTotalTableNames()
Returns total number of registered table names.


getTotalTypes

public int getTotalTypes()
Returns total number of registered types.


reset

public void reset()
Resets the manager and clears descriptors cache.


getColumnAliasSeparator

public java.lang.String getColumnAliasSeparator()
Returns value for separator for column aliases that divides table reference and column name.


setColumnAliasSeparator

public void setColumnAliasSeparator(java.lang.String separator)
Specifies separator for column aliases that divides table reference and column name. Separator should contains of characters that are not used in table names, such as: '$' or '__'.


getHintResolver

public JoinHintResolver getHintResolver()

setHintResolver

public void setHintResolver(JoinHintResolver hintResolver)

getDefaultColumnAliasType

public ColumnAliasType getDefaultColumnAliasType()

setDefaultColumnAliasType

public void setDefaultColumnAliasType(ColumnAliasType defaultColumnAliasType)


Copyright © 2003-2010 Jodd Team