You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by he...@apache.org on 2003/09/12 00:46:10 UTC
cvs commit: db-torque/src/generator/xdocs properties-reference.xml
henning 2003/09/11 15:46:10
Modified: src/generator/src/conf Tag: TORQUE_3_1_BRANCH
build.properties default.properties
src/generator/src/templates/om Tag: TORQUE_3_1_BRANCH
Object.vm Peer.vm
src/generator/xdocs Tag: TORQUE_3_1_BRANCH
properties-reference.xml
Log:
Add a new property "objectIsCaching" that controls whether or not the created
object classes cache their foreign key relations or not. This is necessary if
the application considers torque to be "just a java object mapper" and not a
more complex tool that also keeps internal relationships.
Default is that the object cache their informations, which is the same as the
3.1 release.
Revision Changes Path
No revision
No revision
1.1.2.1 +7 -1 db-torque/src/generator/src/conf/build.properties
Index: build.properties
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/conf/build.properties,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- build.properties 10 Feb 2003 13:22:37 -0000 1.1
+++ build.properties 11 Sep 2003 22:46:09 -0000 1.1.2.1
@@ -83,6 +83,12 @@
# useManagers
# If true, Torque will generate Manager classes that use JCS for caching.
# Still considered experimental.
+#
+# objectIsCaching
+# If true, Torque generates data objects that cache their foreign
+# key relationships. If this is not desired (because the underlying objects
+# can be manipulated from other code), set this property to false. This currently
+# cannot combined with the manager setting from above.
# -------------------------------------------------------------------
torque.targetPackage = org.apache.torque
@@ -95,7 +101,7 @@
torque.complexObjectModel = true
torque.useClasspath = false
torque.useManagers = false
-
+torque.objectIsCaching = true
# -------------------------------------------------------------------
#
1.3.2.1 +2 -0 db-torque/src/generator/src/conf/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/conf/default.properties,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- default.properties 20 Jul 2003 15:41:43 -0000 1.3
+++ default.properties 11 Sep 2003 22:46:09 -0000 1.3.2.1
@@ -104,6 +104,7 @@
complexObjectModel = true
useManagers = false
useClasspath = false
+objectIsCaching = true
torque.addGetByNameMethod = ${addGetByNameMethod}
torque.addIntakeRetrievable = ${addIntakeRetrievable}
@@ -115,6 +116,7 @@
torque.saveException = Exception
torque.useClasspath = ${useClasspath}
torque.useManagers = ${useManagers}
+torque.objectIsCaching = true
torque.omzip.src.base = false
torque.omzip.src.extension = false
No revision
No revision
1.7.2.1 +67 -27 db-torque/src/generator/src/templates/om/Object.vm
Index: Object.vm
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/templates/om/Object.vm,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- Object.vm 19 Aug 2003 09:48:51 -0000 1.7
+++ Object.vm 11 Sep 2003 22:46:09 -0000 1.7.2.1
@@ -206,6 +206,7 @@
#set ( $collName = "coll${tblFK.JavaName}s" )
#end
+ #if ($objectIsCaching)
// update associated $tblFK.JavaName
if ($collName != null)
{
@@ -215,6 +216,7 @@
.set${colFK.JavaName}(v);
}
}
+ #end
#end
#end
#end
@@ -458,6 +460,7 @@
#end
#set ( $collName = "coll$relCol" )
+ #if ($objectIsCaching)
/**
* Collection to store aggregation of $collName
*/
@@ -493,6 +496,7 @@
* The criteria used to select the current contents of $collName
*/
private Criteria last${relCol}Criteria = null;
+ #end
/**
* If this collection has already been initialized, returns
@@ -503,11 +507,15 @@
*/
public List get${relCol}() throws TorqueException
{
+ #if ($objectIsCaching)
if ($collName == null)
{
$collName = get${relCol}(new Criteria(10));
}
return $collName;
+ #else
+ return get${relCol}(new Criteria(10));
+ #end
}
/**
@@ -523,6 +531,7 @@
*/
public List get${relCol}(Criteria criteria) throws TorqueException
{
+ #if ($objectIsCaching)
if ($collName == null)
{
if (isNew())
@@ -531,12 +540,12 @@
}
else
{
- #foreach ($columnName in $fk.ForeignColumns)
- #set ( $column = $table.getColumn($columnName) )
- #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
- #set ( $colFK = $tblFK.getColumn($colFKName) )
+ #foreach ($columnName in $fk.ForeignColumns)
+ #set ( $column = $table.getColumn($columnName) )
+ #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
+ #set ( $colFK = $tblFK.getColumn($colFKName) )
criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}() );
- #end
+ #end
$collName = ${className}Peer.doSelect(criteria);
}
}
@@ -548,12 +557,14 @@
// the following code is to determine if a new query is
// called for. If the criteria is the same as the last
// one, just return the collection.
+ #end
#foreach ($columnName in $fk.ForeignColumns)
#set ( $column = $table.getColumn($columnName) )
#set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
#set ( $colFK = $tblFK.getColumn($colFKName) )
criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
#end
+ #if ($objectIsCaching)
if (!last${relCol}Criteria.equals(criteria))
{
$collName = ${className}Peer.doSelect(criteria);
@@ -563,6 +574,9 @@
last${relCol}Criteria = criteria;
return $collName;
+ #else
+ return ${className}Peer.doSelect(criteria);
+ #end
}
/**
@@ -575,11 +589,15 @@
*/
public List get${relCol}(Connection con) throws TorqueException
{
+ #if ($objectIsCaching)
if ($collName == null)
{
$collName = get${relCol}(new Criteria(10), con);
}
return $collName;
+ #else
+ return get${relCol}(new Criteria(10), con);
+ #end
}
/**
@@ -597,6 +615,7 @@
public List get${relCol}(Criteria criteria, Connection con)
throws TorqueException
{
+ #if ($objectIsCaching)
if ($collName == null)
{
if (isNew())
@@ -605,12 +624,12 @@
}
else
{
- #foreach ($columnName in $fk.ForeignColumns)
- #set ( $column = $table.getColumn($columnName) )
- #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
- #set ( $colFK = $tblFK.getColumn($colFKName) )
+ #foreach ($columnName in $fk.ForeignColumns)
+ #set ( $column = $table.getColumn($columnName) )
+ #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
+ #set ( $colFK = $tblFK.getColumn($colFKName) )
criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
- #end
+ #end
$collName = ${className}Peer.doSelect(criteria, con);
}
}
@@ -622,12 +641,14 @@
// the following code is to determine if a new query is
// called for. If the criteria is the same as the last
// one, just return the collection.
+ #end
#foreach ($columnName in $fk.ForeignColumns)
#set ( $column = $table.getColumn($columnName) )
#set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
#set ( $colFK = $tblFK.getColumn($colFKName) )
criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
#end
+ #if ($objectIsCaching)
if (!last${relCol}Criteria.equals(criteria))
{
$collName = ${className}Peer.doSelect(criteria, con);
@@ -637,6 +658,9 @@
last${relCol}Criteria = criteria;
return $collName;
+ #else
+ return ${className}Peer.doSelect(criteria, con);
+ #end
}
#set ( $countFK = 0 )
@@ -715,6 +739,7 @@
protected List get${relCol}Join${relCol2}(Criteria criteria)
throws TorqueException
{
+ #if ($objectIsCaching)
if ($collName == null)
{
if (isNew())
@@ -723,12 +748,12 @@
}
else
{
- #foreach ($columnName in $fk.ForeignColumns)
- #set ( $column = $table.getColumn($columnName) )
- #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
- #set ( $colFK = $tblFK.getColumn($colFKName) )
+ #foreach ($columnName in $fk.ForeignColumns)
+ #set ( $column = $table.getColumn($columnName) )
+ #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
+ #set ( $colFK = $tblFK.getColumn($colFKName) )
criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
- #end
+ #end
$collName = ${className}Peer.doSelectJoin${relCol2}(criteria);
}
}
@@ -737,6 +762,7 @@
// the following code is to determine if a new query is
// called for. If the criteria is the same as the last
// one, just return the collection.
+ #end
boolean newCriteria = true;
#foreach ($columnName in $fk.ForeignColumns)
#set ( $column = $table.getColumn($columnName) )
@@ -744,6 +770,7 @@
#set ( $colFK = $tblFK.getColumn($colFKName) )
criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
#end
+ #if ($objectIsCaching)
if (!last${relCol}Criteria.equals(criteria))
{
$collName = ${className}Peer.doSelectJoin${relCol2}(criteria);
@@ -752,6 +779,9 @@
last${relCol}Criteria = criteria;
return $collName;
+ #else
+ return ${className}Peer.doSelectJoin${relCol2}(criteria);
+ #end
}
#end
#end
@@ -776,6 +806,7 @@
protected List get${relCol}JoinAllExcept${table.JavaName}(Criteria criteria)
throws TorqueException
{
+ #if ($objectIsCaching)
if ($collName == null)
{
if (isNew())
@@ -784,12 +815,12 @@
}
else
{
- #foreach ($columnName in $fk.ForeignColumns)
- #set ( $column = $table.getColumn($columnName) )
- #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
- #set ( $colFK = $tblFK.getColumn($colFKName) )
+ #foreach ($columnName in $fk.ForeignColumns)
+ #set ( $column = $table.getColumn($columnName) )
+ #set ( $colFKName = $fk.ForeignLocalMapping.get($columnName) )
+ #set ( $colFK = $tblFK.getColumn($colFKName) )
criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
- #end
+ #end
$collName = ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
}
}
@@ -798,6 +829,7 @@
// the following code is to determine if a new query is
// called for. If the criteria is the same as the last
// one, just return the collection.
+ #end
boolean newCriteria = true;
#foreach ($columnName in $fk.ForeignColumns)
#set ( $column = $table.getColumn($columnName) )
@@ -805,6 +837,7 @@
#set ( $colFK = $tblFK.getColumn($colFKName) )
criteria.add(${className}Peer.${colFK.Name.toUpperCase()}, get${column.JavaName}());
#end
+ #if ($objectIsCaching)
if (!last${relCol}Criteria.equals(criteria))
{
$collName = ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
@@ -813,6 +846,9 @@
last${relCol}Criteria = criteria;
return $collName;
+ #else
+ return ${className}Peer.doSelectJoinAllExcept${table.JavaName}${suffix}(criteria);
+ #end
}
#end
@@ -1126,6 +1162,7 @@
#end
#set ( $collName = "coll$relCol" )
+ #if ($objectIsCaching)
if ($collName != null)
{
for (int i = 0; i < ${collName}.size(); i++)
@@ -1133,6 +1170,7 @@
((${className}) ${collName}.get(i)).save(con);
}
}
+ #end
#end
#end
#end
@@ -1432,13 +1470,14 @@
#end
#end
- #if ($relCol == "")
- #set ( $pCollName = "${className}s" )
- #set ( $pCollNameNoS = "${className}" )
- #else
- #set ( $pCollName = "${className}sRelatedBy$relCol" )
- #set ( $pCollNameNoS = "${className}RelatedBy$relCol" )
- #end
+ #if ($objectIsCaching)
+ #if ($relCol == "")
+ #set ( $pCollName = "${className}s" )
+ #set ( $pCollNameNoS = "${className}" )
+ #else
+ #set ( $pCollName = "${className}sRelatedBy$relCol" )
+ #set ( $pCollNameNoS = "${className}RelatedBy$relCol" )
+ #end
${list}v = get${pCollName}();
for (int i = 0; i < v.size(); i++)
@@ -1446,6 +1485,7 @@
$className obj = ($className) v.get(i);
copyObj.add$pCollNameNoS(obj.copy());
}
+ #end
#set ( $list = "" )
#end
#end
1.5.2.2 +8 -0 db-torque/src/generator/src/templates/om/Peer.vm
Index: Peer.vm
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/templates/om/Peer.vm,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -r1.5.2.1 -r1.5.2.2
--- Peer.vm 4 Sep 2003 05:20:28 -0000 1.5.2.1
+++ Peer.vm 11 Sep 2003 22:46:09 -0000 1.5.2.2
@@ -1326,14 +1326,18 @@
if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
{
newObject = false;
+ #if ($objectIsCaching)
temp_obj2.add${collThisTableMs}(obj1);
+ #end
break;
}
}
if (newObject)
{
+ #if ($objectIsCaching)
obj2.init${collThisTable}();
obj2.add${collThisTableMs}(obj1);
+ #end
}
results.add(obj1);
}
@@ -1524,14 +1528,18 @@
if (temp_obj${index}.getPrimaryKey().equals(obj${index}.getPrimaryKey()))
{
newObject = false;
+ #if ($objectIsCaching)
temp_obj${index}.add${collThisTableMs}(obj1);
+ #end
break;
}
}
if (newObject)
{
+ #if ($objectIsCaching)
obj${index}.init${collThisTable}();
obj${index}.add${collThisTableMs}(obj1);
+ #end
}
#end
#end
No revision
No revision
1.4.2.1 +10 -0 db-torque/src/generator/xdocs/properties-reference.xml
Index: properties-reference.xml
===================================================================
RCS file: /home/cvs/db-torque/src/generator/xdocs/properties-reference.xml,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- properties-reference.xml 20 Aug 2003 01:28:43 -0000 1.4
+++ properties-reference.xml 11 Sep 2003 22:46:10 -0000 1.4.2.1
@@ -298,6 +298,16 @@
If true, Torque will generate Manager classes that use JCS for caching.
Still considered experimental.
</td>
+<tr>
+ <td><code> torque.objectIsCaching </code></td>
+ <td><code> true </code></td>
+ <td>
+ If true, Torque generates data objects that cache their foreign
+ key relationships. If this is not desired (because the underlying objects
+ can be manipulated from other code), set this property to false. This currently
+ cannot combined with the manager setting from above.
+ </td>
+</tr>
</tr>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org