|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hydrateframework.SaveContext
public class SaveContext
The SaveContext
class keeps track of the state of Hydrate Objects as they
are saved in the database. You need to create one of these objects before starting
a save session, and you need to wrap the save activity with calls to
beginSave()
/beginTran(java.lang.String)
and finishSave()
/finishTran(String, boolean)
.
The class keeps track of what has been saved so far, ensures that recursive relationships
are saved efficiently, many-to-many tables are updated correctly and that non-HydrateObjects
are tracked.
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
m_log
|
Constructor Summary | |
---|---|
SaveContext(ObjectContext ctx,
RequestContext rc)
Create a new SaveContext |
Method Summary | |
---|---|
void |
beginSave()
Start a save process without a transaction. |
boolean |
beginTran(java.lang.String name)
Start a save process with a transaction. |
void |
deferReadKey(NamedParameterStatement stmt,
java.lang.Object obj)
Defer the reading of a database generated key. |
void |
dump(java.io.PrintStream out)
Dump out the details of the save context showing how many objects have been saved and how many are scheduled for later saving. |
void |
finishSave()
Complete a non transactional save process, or one in which the transaction is controlled externally. |
boolean |
finishTran(java.lang.String name,
boolean commit)
Complete a transactional save process. |
void |
flushStatement(ObjectContext ctx,
java.lang.Class cls)
Flush a statement that was used to update or insert objects in batch mode. |
RequestContext |
getRequestContext()
Get the request context |
boolean |
isInTransaction(java.lang.String name)
return the transaction status of the save session |
boolean |
isSaved(java.lang.Object bo)
Determine if the given object has been saved in this session |
void |
needKeyNow(ObjectContext ctx,
java.lang.Object obj)
Call this method when a generated key is accessed. |
HydrateObject |
proxy(java.lang.Object o)
Proxy a non-hydrate object with an HydrateObject. |
void |
saveLater(java.lang.Object bo)
Add an object to the list of objects that must be saved at the end of the session if not already saved. |
void |
saveLaterMTM(java.lang.String relationshipName,
java.util.Collection<ObjectRelationshipFactory.RelationshipMap> coll)
Add a many to many relationship that will be saved at the end of the session. |
void |
saveMTMs(ObjectCollection<HydrateObject> coll)
|
void |
setSaved(java.lang.Object bo)
Establish an object as having been saved |
void |
unsetSaved(java.lang.Object bo)
Mark an object as not having been saved. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log m_log
Constructor Detail |
---|
public SaveContext(ObjectContext ctx, RequestContext rc)
ctx
- the object context from which objects will be saved.rc
- the request context that has the connections and queries for the save.Method Detail |
---|
public RequestContext getRequestContext()
public HydrateObject proxy(java.lang.Object o)
o
- the object to be proxied. If it is already an HydrateObject, the method
simply returns a reference to this object.
public boolean isSaved(java.lang.Object bo)
bo
- the object for which save status is required
public void setSaved(java.lang.Object bo)
bo
- the object that has been saved.public void unsetSaved(java.lang.Object bo)
bo
- the object to be markedpublic void saveLater(java.lang.Object bo)
bo
- public void saveLaterMTM(java.lang.String relationshipName, java.util.Collection<ObjectRelationshipFactory.RelationshipMap> coll)
relationshipName
- the name of the relationship to be savedcoll
- the collection that holds the referencespublic boolean isInTransaction(java.lang.String name)
name
- the name of the connection that is the commit agent
public void saveMTMs(ObjectCollection<HydrateObject> coll)
public void beginSave()
beginTran(String)
method must be called after creating the SaveContext
, but before
saving any objects.
public void finishSave() throws SaveException
beginSave()
.
SaveException
public boolean beginTran(java.lang.String name)
beginSave()
method must be called after creating the SaveContext
, but before
saving any objects.
name
- the name of the transaction.
public boolean finishTran(java.lang.String name, boolean commit) throws SaveException
beginTran(java.lang.String)
.
name
- the name of the transaction.commit
- true if the transaction is being committed, false otherwise.
SaveException
public void dump(java.io.PrintStream out)
out
- the stream to write to.public void needKeyNow(ObjectContext ctx, java.lang.Object obj) throws SaveException
ctx
- the object context containing objects and factoriesobj
- the object that needs a key - all outstanding objects of this type will be
resolved
SaveException
public void flushStatement(ObjectContext ctx, java.lang.Class cls) throws SaveException
ctx
- the object context used in the savecls
- the class of object that is to be flushed
SaveException
public void deferReadKey(NamedParameterStatement stmt, java.lang.Object obj)
stmt
- the statement that is being batched up.obj
- the object that won't have a key because of the batching process.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |