public class MetaModel extends Object implements Serializable
Modifier | Constructor and Description |
---|---|
protected |
MetaModel(String dbName,
Class<? extends Model> modelClass,
String dbType) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAssociation(Association association) |
boolean |
cached() |
protected void |
checkAttribute(String attribute)
Checks if this model has a named attribute that has the same name as argument.
|
void |
clearShardTableName()
Clears sharding name of table attached to current thread.
|
<A extends Association> |
getAssociationForTarget(Class<? extends Model> targetClass)
Returns association of this table with the target table.
|
<A extends Association> |
getAssociationForTarget(Class<? extends Model> targetModelClass,
Class<A> associationClass)
Returns association of this table with the target table.
|
protected List<Association> |
getAssociations() |
List<Association> |
getAssociationsForTarget(Class<? extends Model> targetModelClass)
Returns associations of this table with the target table.
|
protected Set<String> |
getAttributeNames()
Retrieves all attribute names.
|
Set<String> |
getAttributeNamesSkip(String... names)
Finds all attribute names except those provided as arguments.
|
Set<String> |
getAttributeNamesSkipGenerated()
Convenience method.
|
Set<String> |
getAttributeNamesSkipGenerated(boolean managed)
Finds all attribute names except managed like
id ,
created_at , updated_at and record_version , depending on argument. |
Set<String> |
getAttributeNamesSkipId()
Finds all attribute names except for id.
|
Map<String,ColumnMetadata> |
getColumnMetadata()
Provides column metadata map, keyed by attribute names.
|
String[] |
getCompositeKeys()
Returns optional composite primary key class
|
String |
getDbName() |
protected static String |
getDbName(Class<? extends Model> modelClass) |
String |
getDbType() |
Dialect |
getDialect() |
String |
getFKName()
FK name is a foreign key name used in relationships as a foreign key column in a child table (table represented by this
instance is a parent table).
|
String |
getIdGeneratorCode() |
String |
getIdName() |
protected List<Many2ManyAssociation> |
getManyToManyAssociations(Association... excludedAssociations) |
Class<? extends Model> |
getModelClass() |
protected List<OneToManyAssociation> |
getOneToManyAssociations(Association... excludedAssociations) |
String[] |
getPartitionIDs() |
protected List<OneToManyPolymorphicAssociation> |
getPolymorphicAssociations(Association... excludedAssociations) |
String |
getTableName()
Returns table name currently associated with this model.
|
String |
getVersionColumn() |
protected boolean |
hasAssociation(Class<? extends Model> targetClass,
Class<? extends Association> associationClass) |
boolean |
hasPartitionIDs() |
boolean |
isAssociatedTo(Class<? extends Model> targetModelClass)
Checks if there is association to the target model class.,
|
boolean |
isVersioned()
Returns true if this model supports optimistic locking, false if not
|
void |
removeAssociationForTarget(Class<? extends Model> modelClass) |
void |
setFKName(String fkName) |
void |
setShardTableName(String tableName)
This feature is for sharding!
Do not use it to set table names willy-nilly! |
protected boolean |
tableExists() |
String |
toString() |
public boolean hasPartitionIDs()
public String[] getPartitionIDs()
public void setShardTableName(String tableName)
This feature is for sharding!
Do not use it to set table names willy-nilly!
Sets a table name for this model. The table name is attached to a current thread and will remain there
until it is set with a different value or cleared with clearShardTableName()
method.
Table name set with this method overrides a table name naturally mapped to this model.
Method getTableName()
will return this value for all operations related to this table.
tableName
- name of a table this model will read from current thread.public void clearShardTableName()
setShardTableName(String)
method. After execution of this class, the method getTableName()
will be
returning the value this MetaModel
was initialized with during teh bootstrap phase.public String getVersionColumn()
public String getIdGeneratorCode()
public String getDbName()
public boolean cached()
public String getTableName()
setShardTableName(String)
protected boolean tableExists()
public Set<String> getAttributeNamesSkipId()
public Set<String> getAttributeNamesSkipGenerated()
getAttributeNamesSkipGenerated(boolean)
and passes true
as argument.public Set<String> getAttributeNamesSkipGenerated(boolean managed)
id
,
created_at
, updated_at
and record_version
, depending on argument.managed
- if true, time managed attributes created_at
and updated_at
will not be included (they are managed automatically).
If false (not managed) created_at
and updated_at
will be included in output.id
, created_at
, updated_at
and
record_version
, depending on argument.public Set<String> getAttributeNamesSkip(String... names)
public boolean isVersioned()
protected Set<String> getAttributeNames()
public String getIdName()
public String[] getCompositeKeys()
public <A extends Association> A getAssociationForTarget(Class<? extends Model> targetModelClass, Class<A> associationClass)
targetModelClass
- association of this model and the target model.associationClass
- class of association in requested.public <A extends Association> A getAssociationForTarget(Class<? extends Model> targetClass)
targetClass
- association of this model and the target model.public List<Association> getAssociationsForTarget(Class<? extends Model> targetModelClass)
targetModelClass
- association of this model and the target model.protected void addAssociation(Association association)
protected boolean hasAssociation(Class<? extends Model> targetClass, Class<? extends Association> associationClass)
public String getFKName()
Inflector
: It is a singular version of this table name plus "_id".protected List<OneToManyAssociation> getOneToManyAssociations(Association... excludedAssociations)
protected List<OneToManyPolymorphicAssociation> getPolymorphicAssociations(Association... excludedAssociations)
protected List<Many2ManyAssociation> getManyToManyAssociations(Association... excludedAssociations)
public String getDbType()
public Dialect getDialect()
protected List<Association> getAssociations()
protected void checkAttribute(String attribute)
IllegalArgumentException
in case it does not find it.attribute
- name of attribute or association target.public Map<String,ColumnMetadata> getColumnMetadata()
public boolean isAssociatedTo(Class<? extends Model> targetModelClass)
targetModelClass
- class of a model that will be checked for association from current model.public void removeAssociationForTarget(Class<? extends Model> modelClass)
public void setFKName(String fkName)
Copyright © 2020 JavaLite. All rights reserved.