The VersionGenerator is able to clone a version of a row
in a database. That is nothing special. A simple INSERT does
the same.
The difference is that the VersionGenerator is able to
clone rows in other tables referencing the cloned table
as well, updating the references, and clone and update rows
referencing these cloned and updated rows, and so on.
In other words: The VersionGenerator derives a new
version of a complex object stored in the database.
The VersionGenerator operates on a list of tables. This
list must not contain forward or self references. In other
words: Under no circumstances may a table in the list contain
a foreign key referencing another table, which follows later.
addTable
public void addTable(Table pTable,
VersionGenerator.ColumnUpdater pUpdater)
Adds a new table to the list of tables. The table must not
contain a forward reference. Additionally, the table must not
be referenced by any other table, which has already been added
to the list.
pTable
- The table being clonedpUpdater
- The column updater to use for changing the
updated columns.
getCacheDataClassName
protected JavaQName getCacheDataClassName(JavaQName pQName)
Returns the name of the inner class CacheData.
getCloneMethod
public JavaMethod getCloneMethod(JavaSource pSource)
Creates a method for updating one row in the head table.
getInsertRowMethodName
protected String getInsertRowMethodName(VersionGenerator.TableInfo pTableInfo)
Returns the name of the method for cloning one row from the
given table.
getPublicCloneMethod
protected JavaMethod getPublicCloneMethod(JavaSource pSource)
Actually creates the public "clone" method.
initLogging
protected void initLogging(JavaSource pSource)
Creates the code for initialization of the logging framework.
The default implementation generates code creating an instance of
Logger
.
isGeneratingLogging
public boolean isGeneratingLogging()
Returns whether the generator is creating logging statements. By default
no logging statements are created.
The default
implementation creates logging statements suitable for the JaxMe logging
package. To change this, create a subclass and overwrite the following
methods:
logEntering(JavaMethod,Object)
,
logExiting(JavaMethod,Object)
,
logFinest(JavaMethod,Object,Object)
,
logFinestEntering(JavaMethod,Object)
, and
logFinestExiting(JavaMethod,Object)
.
logEntering
protected void logEntering(JavaMethod pMethod,
Object pValues)
Creates code for logging the entrance into a method with
fine level.
Note: The method should consider the
isGeneratingLogging()
value.
pMethod
- The method in which a logging statement should be insertedpValues
- An array of additional values, possibly null
logExiting
protected void logExiting(JavaMethod pMethod,
Object pValues)
Creates code for logging the exit from a method with
fine level.
Note: The method should consider the
isGeneratingLogging()
value.
pMethod
- The method in which a logging statement should be insertedpValues
- An array of additional values, possibly null
logFinest
protected void logFinest(JavaMethod pMethod,
Object pMsg,
Object pValues)
Creates code for logging a message with finest level.
Note: The method should consider the
isGeneratingLogging()
value.
pMethod
- The method in which a logging statement should be insertedpMsg
- The message being loggedpValues
- An array of additional values, possibly null
logFinestEntering
protected void logFinestEntering(JavaMethod pMethod,
Object pValues)
Creates code for logging the entrance into a method with
finest level.
Note: The method should consider the
isGeneratingLogging()
value.
Implementation note: The default implementation is
equivalent to
logFinest(pMethod, "->", pValues)
.
pMethod
- The method in which a logging statement should be insertedpValues
- An array of additional values, possibly null
logFinestExiting
protected void logFinestExiting(JavaMethod pMethod,
Object pValues)
Creates code for logging the exit from a method with
fine level.
Note: The method should consider the
isGeneratingLogging()
value.
Implementation note: The default implementation is
equivalent to
logFinest(pMethod, "<-", pValues)
.
pMethod
- The method in which a logging statement should be insertedpValues
- An array of additional values, possibly null
setGeneratingLogging
public void setGeneratingLogging(boolean pGeneratingLogging)
Sets whether the generator is creating logging statements. By default
no logging statements are created.
The default
implementation creates logging statements suitable for the JaxMe logging
package. To change this, create a subclass and overwrite the following
methods:
logEntering(JavaMethod,Object)
,
logExiting(JavaMethod,Object)
,
logFinest(JavaMethod,Object,Object)
,
logFinestEntering(JavaMethod,Object)
, and
logFinestExiting(JavaMethod,Object)
.
setPreparedStatementValue
protected void setPreparedStatementValue(JavaMethod pMethod,
Column pColumn,
Object pStmt,
Object pParamNum,
Object pValue)
Generates code for setting a PreparedStatement's parameter.
setResultSetValue
protected void setResultSetValue(JavaMethod pMethod,
Column pColumn,
DirectAccessible pResultSet,
int pColumnNum,
Object pTarget)
Generates code for reading a ResultSet's column.