public abstract class PersistentObject extends Object implements Persistent, Cloneable
Persistent
interface. All methods apart from Persistent.getTableName()
are implemented with default behaviour.KeyValuePair
interface. So persistent objects become key value pairs, where the object's
OID is the key and the object's String
representation is the
value.Modifier and Type | Field and Description |
---|---|
protected boolean |
filled |
protected long |
oid |
emptyKeys
Constructor and Description |
---|
PersistentObject() |
Modifier and Type | Method and Description |
---|---|
void |
afterDelete()
This method is called after the persistent object has been deleted.
|
void |
afterInsert()
This method is called after the persistent object has been inserted into
the store.
|
void |
afterRead()
This method is called after the persistent object has been read.
|
void |
afterUpdate()
This method is called after the persistent object has been updated in the
store.
|
void |
beforeDelete()
This method is called before the persistent object is deleted.
|
void |
beforeInsert()
This method is called before the persistent object is inserted into
the store.
|
void |
beforeUpdate()
This method is called before the persistent object is updated in the
store (the existing object in the store will be overwritten with the
values of this object).
|
Object |
clone() |
List<Field> |
dbFields()
Returns the persistent fields of this object in a
List
containing java.lang.reflect.Field objects. |
boolean |
equals(Object o)
Compares two persistent objects and returns
true if they
are equal (i.e., they must have the same OID and the same class). |
String |
getKey()
Returns the key (className:OID) of this
KeyValuePair . |
String[][] |
getKeys()
A class may return key field groups in order to identify already existing objects
of that class.
|
String |
getLocalClassName() |
String |
getLocalObjectName()
Get the object name in localized form.
|
long |
getOid()
Getter method for the persistent object's OID.
|
Store |
getStore()
Returns the
Store object which is responsible for storing this
persistence object. |
String |
getValue()
Returns the value (
String representation) of this
KeyValuePair . |
int |
hashCode()
Returns a hash code for this persistent object.
|
boolean |
isFilled()
With this method you check if this persistent object is filled with
persistent data or not.
|
void |
isValid()
Overwrite this method to check ids, etc.
|
void |
onDelete()
Deprecated.
since ep 9.0 will be removed in 10.0. Use
beforeDelete() instead. |
void |
onInsert()
Deprecated.
since ep 9.0 will be removed in 10.0. Use
beforeInsert() instead. |
void |
onRead()
Deprecated.
since ep 9.0 will be removed in 10.0. Use
afterRead() instead. |
void |
onUpdate()
Deprecated.
since ep 9.0 will be removed in 10.0. Use
beforeUpdate() instead. |
void |
setFilled(boolean f)
This method can change the filled status of this persistent
object.
|
void |
setOid()
Setter method for the persistent object's OID.
|
void |
setOid(long oid)
Setter method for the persistent object's OID.
|
void |
setStore(Store store)
With this method you can change the
Store of this persistent object. |
String |
toListString()
Returns a special string representation of the object.
|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getTableName
public long getOid()
Persistent
getOid
in interface Persistent
public void setOid(long oid)
Persistent
setOid
in interface Persistent
oid
- The new OID for the object.public void setOid()
Persistent
setOid
in interface Persistent
public void setFilled(boolean f)
Persistent
Persistent.isFilled()
for more details.setFilled
in interface Persistent
f
- The new value for the filled status.public boolean isFilled()
Persistent
Store
to fill it.isFilled
in interface Persistent
true
if the object is filled with values, or
false
if the object is empty (only OID is set).public Store getStore()
Store
object which is responsible for storing this
persistence object.getStore
in interface Persistent
Store
of this persistent object.public void setStore(Store store)
Persistent
Store
of this persistent object.
Usually objects are stored in the system's database and you will never need
to set the Store
manually.setStore
in interface Persistent
store
- The new Store
that will be set for this persistent object.public List<Field> dbFields()
List
containing java.lang.reflect.Field
objects.dbFields
in interface Persistent
List
containing the persistent fields of this
persistent object. The List
must contain the fields
as java.lang.reflect.Field
objects.@Deprecated public void onInsert()
beforeInsert()
instead.@Deprecated public void onUpdate()
beforeUpdate()
instead.@Deprecated public void onDelete()
beforeDelete()
instead.@Deprecated public void onRead()
afterRead()
instead.public void beforeInsert()
Persistent
beforeInsert
in interface Persistent
Persistent.beforeInsert()
public void afterInsert()
Persistent
afterInsert
in interface Persistent
Persistent.afterInsert()
public void beforeUpdate()
Persistent
beforeUpdate
in interface Persistent
Persistent.beforeUpdate()
public void afterUpdate()
Persistent
afterUpdate
in interface Persistent
Persistent.afterUpdate()
public void beforeDelete()
Persistent
Store.delete(Class, String, Object[])
and
Store.delete(String, String, Object[])
methods do NOT call Persistent.beforeDelete()
.beforeDelete
in interface Persistent
Persistent.beforeDelete()
public void afterDelete()
Persistent
Store.delete(Class, String, Object[])
and
Store.delete(String, String, Object[])
methods do NOT call Persistent.afterDelete()
.afterDelete
in interface Persistent
Persistent.afterDelete()
public void afterRead()
Persistent
afterRead
in interface Persistent
Persistent.afterRead()
public boolean equals(Object o)
true
if they
are equal (i.e., they must have the same OID and the same class).public int hashCode()
public String getKey()
KeyValuePair
.getKey
in interface KeyValuePair<String,String>
getKey
in interface Persistent
public String getValue()
String
representation) of this
KeyValuePair
.getValue
in interface KeyValuePair<String,String>
getValue
in interface Persistent
public String getLocalObjectName()
getLocalObjectName
in interface Persistent
public String getLocalClassName()
getLocalClassName
in interface Persistent
public String toListString()
toListString
in interface Persistent
public void isValid()
isValid
in interface Persistent
public String[][] getKeys()
Persistent
The first key field group is occasionally treated in a special manner as the primary business key. E.g. the export import functionality checks for object existence according to just the first key field group.
If no key field groups can be provided by the implementing class an empty result must be returned - use Persistent.emptyKeys
to do so.
getKeys
in interface Persistent
{{"name", "birthdate"},{"ssn"}}
for a
class defining two key field groups. The first one contains the fields name
and
birthdate
, the second key field group has just one field ssn
.@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.