|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjects.Record
de.mguennewig.pobjects.PObject
public abstract class PObject
Represents a table row with an id that is unique within the table.
Unlike Record, instances of this type have an identity and
can be written to. Using store(), changes to the in-memory
object are propagated back to the RDBMS.
| Field Summary | |
|---|---|
static int |
CHECK_ALL_FIELDS
Constant that specifies that restrictions of all fields will be checked on store(int). |
static int |
CHECK_CHANGED_ONLY
Constant that specifies that only the restrictions of changed fields will be checked on store(int). |
static int |
CHECK_NOTHING
Constant that specifies that no field restrictions will be checked on store(int). |
static int |
STATE_COMMITED
A pseudo state that will not really change state
but will clear the getOldValues() hash after a commit has been
issued. |
static int |
STATE_DELETE
The object is marked for deletion. |
static int |
STATE_DIRTY
The object has been read from the database, and one or more of its fields have been changed in memory. |
static int |
STATE_INTERNALIZED
The object mirrors an existing database row. |
static int |
STATE_INVALID
|
static int |
STATE_NEW_OBJECT
Container.makePersistent(PObject) has been called on the object,
but the object has not been stored yet. |
static int |
STATE_REFERENCE
The object in memory is only a reference to the real data stored in the database. |
static int |
STATE_TRANSIENT
|
| Constructor Summary | |
|---|---|
PObject()
Standard-constructor for PObject. |
|
| Method Summary | |
|---|---|
void |
checkConstraints()
Tests whether the current in memory state violates any Constraints. |
void |
checkConstraints(int fieldCheck)
Tests whether the current in memory state violates any Constraints. |
void |
copyState(PObject src)
Copies the state of the given object into this object. |
void |
delete()
Deletes the object from the RDBMS. |
java.util.Map<java.lang.Integer,java.lang.Object> |
getChangedValues()
Returns a map of changed values where the field index is the key and the new value the value. |
abstract ClassDecl |
getClassDecl()
|
Container |
getContainer()
Returns the database container to which this object belongs. |
static int |
getDefaultFieldCheckStyle()
Returns how strict or loose field restrictions are checked by default on every store() and checkConstraints(). |
java.lang.String |
getId()
Returns the unique database identifier within its class if the object is persistent, and null otherwise. |
java.lang.String |
getIdForVisual()
|
static java.lang.String |
getKey(ClassDecl te,
java.lang.String id)
|
static java.lang.String |
getKey(PObject obj)
|
java.util.Map<java.lang.Integer,java.lang.Object> |
getOldValues()
Returns a map of changed values, where the field index is the key and the old value the value. |
int |
getPObjState()
|
TableExpr |
getTableExpr()
Returns the metadata declaration for this Record. |
boolean |
isInstanceOf(ClassDecl table)
Tests whether this persistent object is an instance of table expression table. |
boolean |
isInternalized()
Tests whether the object is fully read from the RDBMS. |
boolean |
isPersistent()
Tests whether the object is known to the RDBMS. |
boolean |
isReference()
|
void |
loadForUpdate()
|
void |
loadIfReference()
|
void |
revert()
Reverts the in-memory state to the last committed or read one. |
void |
set(Column c,
java.lang.Object value)
Set value of column c. |
static void |
setDefaultFieldCheckStyle(int fieldCheck)
Sets how strict or loose field restrictions are checked by default on every store() and checkConstraints(). |
void |
store()
Saves the current in memory state in the RDBMS. |
void |
store(int fieldCheck)
Saves the current in memory state in the RDBMS. |
java.lang.String |
toString()
Returns a textual representation for this class. |
| Methods inherited from class de.mguennewig.pobjects.Record |
|---|
format, get, get, set |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int CHECK_ALL_FIELDS
store(int). This is the default for new objects unless
CHECK_NOTHING has been specified.
public static final int CHECK_CHANGED_ONLY
store(int). This will speed up storing
slightly and will make the application more robust if more strict
constraints will be applied at later points in time of the application.
Note that for new objects this is equivalent to
CHECK_ALL_FIELDS.
public static final int CHECK_NOTHING
store(int).
NOTE: That this can lead to inconsistent database content and is highly discouraged to use.
public static final int STATE_INVALID
public static final int STATE_TRANSIENT
public static final int STATE_REFERENCE
public static final int STATE_NEW_OBJECT
Container.makePersistent(PObject) has been called on the object,
but the object has not been stored yet. Since the object only exists in
memory, there can be no external references to it. This means the
container is defined, but the id
remains null.
public static final int STATE_INTERNALIZED
container and id are set and
changes to the object mark it as dirty with respect to the database
content.
public static final int STATE_DIRTY
store() will execute
an UPDATE to bring the database in sync with the in-memory object.
public static final int STATE_DELETE
store() on it
will trigger a DELETE statement for it in the database.
public static final int STATE_COMMITED
state
but will clear the getOldValues() hash after a commit has been
issued.
| Constructor Detail |
|---|
public PObject()
| Method Detail |
|---|
public final boolean isInstanceOf(ClassDecl table)
table.
true if table is a base table of this, otherwise
false.ClassDecl.isExtensionOf(TableExpr)public void copyState(PObject src)
This method copies only the data defined by the table expression of the given object into this object. The id is skipped in this process.
java.lang.IllegalArgumentException - if src is not an instance of
a base class of this object.isInstanceOf(ClassDecl)public final java.util.Map<java.lang.Integer,java.lang.Object> getOldValues()
getChangedValues()public final java.util.Map<java.lang.Integer,java.lang.Object> getChangedValues()
getOldValues()public final java.lang.String getId()
null otherwise.
public java.lang.String getIdForVisual()
public final Container getContainer()
public final boolean isPersistent()
public final boolean isInternalized()
public abstract ClassDecl getClassDecl()
public final TableExpr getTableExpr()
Record.
getTableExpr in class RecordgetClassDecl()public final int getPObjState()
public static int getDefaultFieldCheckStyle()
store() and checkConstraints().
CHECK_ALL_FIELDS,
CHECK_CHANGED_ONLY,
CHECK_NOTHINGpublic static void setDefaultFieldCheckStyle(int fieldCheck)
store() and checkConstraints().
CHECK_ALL_FIELDS,
CHECK_CHANGED_ONLY,
CHECK_NOTHINGpublic static java.lang.String getKey(PObject obj)
public static java.lang.String getKey(ClassDecl te,
java.lang.String id)
public final boolean isReference()
public void loadIfReference()
public void loadForUpdate()
public void revert()
public void set(Column c,
java.lang.Object value)
c.
This method is primarily intended for use by procedures that work on
meta level of de.mguennewig.pobjects. It differs from the per
field setXXX() methods in that it does not load the object's
data if it is not in memory. If unsure whether the object's state has been
internalized, then any call to this method must be preceded by a
call to loadIfReference().
Saves old value if changed the first time.
set in class RecordsaveOldValue(int,Object),
revert()
public void delete()
throws PObjSQLException
If the objects data is not in memory yet, then it will be loaded before
actually deleting it. This ensures that access to an object's data after
delete() and store() is consistent and always returns "real"
data, instead of just null.
PObjSQLExceptionloadIfReference()
public void checkConstraints()
throws PObjConstraintException
Constraints.
Note: UniqueConstraints can't be checked in memory.
PObjConstraintException - when any Constraint is violated.UniqueConstraint
public void checkConstraints(int fieldCheck)
throws PObjConstraintException
Constraints.
Note: UniqueConstraints can't be checked in memory.
fieldCheck - Specified how strict or loose the field restrictions
should be checked. This will be one of CHECK_ALL_FIELDS,
CHECK_CHANGED_ONLY or CHECK_NOTHING.
PObjConstraintException - when any Constraint is violated.UniqueConstraint
public void store()
throws PObjConstraintException,
PObjSQLException
java.lang.IllegalStateException - if this object is new and
Container.makePersistent(PObject) has not been called yet.
PObjConstraintException - when any Constraint is violated.
PObjSQLException - when any other database exception occurs.checkConstraints()
public void store(int fieldCheck)
throws PObjConstraintException,
PObjSQLException
fieldCheck - Specified how strict or loose the field restrictions
should be checked. This will be one of CHECK_ALL_FIELDS,
CHECK_CHANGED_ONLY or CHECK_NOTHING.
java.lang.IllegalStateException - if this object is new and
Container.makePersistent(PObject) has not been called yet.
PObjConstraintException - when any Constraint is violated.
PObjSQLException - when any other database exception occurs.checkConstraints(int)public java.lang.String toString()
toString in class java.lang.Objectvisualization field
if set, else a string of the form
[<table>:<id>].
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||