public abstract class SQLEntity extends BaseEntity<Long>
OMA
and stored in
a JDBC / SQL database.Modifier and Type | Field and Description |
---|---|
protected Row |
fetchRow |
protected long |
id |
static Mapping |
ID
Contains the unique ID of the entity.
|
static long |
NON_PERSISTENT_ENTITY_ID
Represents the id which signals that the entity was not persisted yet.
|
protected static OMA |
oma |
mixing, NEW, persistedData, version
Constructor and Description |
---|
SQLEntity() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
Indicates whether some other object is "equal to" this one.
|
Row |
getFetchRow()
If the entity was created as the result of a
TransformedQuery , the original Row is
accessible via this method. |
Long |
getId()
Returns the ID of the entity.
|
<E extends BaseEntity<?>,C extends Constraint,Q extends Query<Q,E,C>> |
getMapper()
Provides the
mapper which is used to actually manage the entity. |
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isNew()
Determines if the entity is new (not yet written to the database).
|
protected boolean |
isUnique(Mapping field,
Object value,
Mapping... within)
Determines if the given value in the given field is unique within the given side constraints.
|
void |
setId(long id)
Sets the ID of the entity.
|
assertUnique, getDescriptor, getIdAsString, getTypeName, getUniqueName, getVersion, isAnyMappingChanged, isChanged, setVersion, toString
is, makeNewInstance, tryAs
public static final long NON_PERSISTENT_ENTITY_ID
protected static OMA oma
public static final Mapping ID
This is automatically assigned by the database. Never assign manually a value unless you are totally aware of what you're doing. Also you should not use this ID for external purposes (e.g. as customer number or invoice number) as it cannot be changed.
This field is marked as transient as this column is automatically managed by the framework.
protected long id
protected Row fetchRow
public boolean isNew()
BaseEntity
isNew
in class BaseEntity<Long>
public <E extends BaseEntity<?>,C extends Constraint,Q extends Query<Q,E,C>> BaseMapper<E,C,Q> getMapper()
BaseEntity
mapper
which is used to actually manage the entity.getMapper
in class BaseEntity<Long>
E
- the entity type of the mapperQ
- the query type of the mapperpublic Long getId()
getId
in class BaseEntity<Long>
public void setId(long id)
This method must be used very carefully. For normal operations, this method should ne be used at all as the database ID is managed by the framework.
id
- the id of the entity in the databasepublic int hashCode()
HashMap
.
The hash code of an entity is based on its ID. If the entity is not written to the database yet, we use
the hash code as computed by Object.hashCode()
. This matches the behaviour of equals(Object)
.
hashCode
in class BaseEntity<Long>
public boolean equals(Object other)
BaseEntity
Equality of two entities is based on their type and ID. If an entity is not written to the database yet, we
determine equality as computed by Object.equals(Object)
. This matches the behaviour of
BaseEntity.hashCode()
.
equals
in class BaseEntity<Long>
true
if this object is the same as the obj
argument; false
otherwise.protected boolean isUnique(Mapping field, Object value, Mapping... within)
BaseEntity
isUnique
in class BaseEntity<Long>
field
- the field to checkvalue
- the value to be uniquewithin
- the side constraints within the value must be uniquepublic Row getFetchRow()
TransformedQuery
, the original Row
is
accessible via this method.Copyright © 2018. All rights reserved.