public class DbEntityManager
extends java.lang.Object
Important: configure settings before entity registration!
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.
It is not needed to use mappings at all: in that case just provide entity types during the conversion of
result set to objects.
Modifier and Type | Field and Description |
---|---|
protected TypeCache<DbEntityDescriptor> |
descriptorsMap |
protected java.util.Map<java.lang.String,DbEntityDescriptor> |
entityNamesMap |
protected java.lang.String[] |
primitiveEntitiesPrefixes |
protected java.util.Map<java.lang.String,DbEntityDescriptor> |
tableNamesMap |
Constructor and Description |
---|
DbEntityManager(DbOomConfig dbOomConfig) |
Modifier and Type | Method and Description |
---|---|
protected <E> DbEntityDescriptor<E> |
createDbEntityDescriptor(java.lang.Class<E> type)
Creates
DbEntityDescriptor . |
<E> E |
createEntityInstance(java.lang.Class<E> type)
Creates new entity instances.
|
void |
forEachEntity(java.util.function.Consumer<DbEntityDescriptor> consumer) |
java.lang.String[] |
getPrimitiveEntitiesPrefixes() |
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.
|
DbEntityDescriptor |
lookupName(java.lang.String typeName)
Lookups for
DbEntityDescriptor that was registered with this manager. |
DbEntityDescriptor |
lookupTableName(java.lang.String tableName)
Lookups for
DbEntityDescriptor that was registered with this manager. |
<E> DbEntityDescriptor<E> |
lookupType(java.lang.Class<E> type)
Lookups
DbEntityDescriptor for some type and registers the type if is new. |
<E> DbEntityDescriptor<E> |
registerEntity(java.lang.Class<E> type)
Registers entity.
|
<E> DbEntityDescriptor<E> |
registerEntity(java.lang.Class<E> type,
boolean force)
Registers entity.
|
<E> DbEntityDescriptor<E> |
registerType(java.lang.Class<E> type)
Registers just type and entity names.
|
<E> DbEntityDescriptor<E> |
removeEntity(java.lang.Class<E> type)
Removes entity and returns removed descriptor.
|
void |
reset()
Resets the manager and clears descriptors maps.
|
void |
setPrimitiveEntitiesPrefixes(java.lang.String... primitiveEntitiesPrefixes)
Specifies array of class name prefixes that will be mapped directly to column.
|
protected java.lang.String[] primitiveEntitiesPrefixes
protected TypeCache<DbEntityDescriptor> descriptorsMap
protected java.util.Map<java.lang.String,DbEntityDescriptor> entityNamesMap
protected java.util.Map<java.lang.String,DbEntityDescriptor> tableNamesMap
public DbEntityManager(DbOomConfig dbOomConfig)
public java.lang.String[] getPrimitiveEntitiesPrefixes()
public void setPrimitiveEntitiesPrefixes(java.lang.String... primitiveEntitiesPrefixes)
public <E> DbEntityDescriptor<E> lookupType(java.lang.Class<E> type)
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.
public DbEntityDescriptor lookupName(java.lang.String typeName)
DbEntityDescriptor
that was registered with this manager.
Returns null
if name not found.public DbEntityDescriptor lookupTableName(java.lang.String tableName)
DbEntityDescriptor
that was registered with this manager.
Returns null
if table name not found. Lookup is case-insensitive.public <E> DbEntityDescriptor<E> registerType(java.lang.Class<E> type)
public <E> DbEntityDescriptor<E> registerEntity(java.lang.Class<E> type)
Registers types
and table names.public <E> DbEntityDescriptor<E> registerEntity(java.lang.Class<E> type, boolean force)
public <E> DbEntityDescriptor<E> removeEntity(java.lang.Class<E> type)
protected <E> DbEntityDescriptor<E> createDbEntityDescriptor(java.lang.Class<E> type)
DbEntityDescriptor
.public int getTotalNames()
public int getTotalTableNames()
public int getTotalTypes()
public void reset()
public <E> E createEntityInstance(java.lang.Class<E> type)
public void forEachEntity(java.util.function.Consumer<DbEntityDescriptor> consumer)
Copyright © 2003-present Jodd Team