db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henn...@apache.org
Subject cvs commit: db-torque/proposals/henning/skipidbroker skipidbroker.patch
Date Thu, 23 Oct 2003 16:31:02 GMT
henning     2003/10/23 09:31:02

  Modified:    proposals/henning/skipidbroker Tag: TORQUE_3_1_BRANCH
                        skipidbroker.patch
  Log:
  If we don't use the IdBroker, buildCriteria() must contain the value for
  this column, else we get not null violations. Fix the Peer template
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +50 -12    db-torque/proposals/henning/skipidbroker/Attic/skipidbroker.patch
  
  Index: skipidbroker.patch
  ===================================================================
  RCS file: /home/cvs/db-torque/proposals/henning/skipidbroker/Attic/skipidbroker.patch,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- skipidbroker.patch	23 Oct 2003 16:08:02 -0000	1.1.2.2
  +++ skipidbroker.patch	23 Oct 2003 16:31:02 -0000	1.1.2.3
  @@ -1,7 +1,7 @@
   diff --exclude=CVS -Nurb db-torque_BRANCH31.patched/src/generator/src/templates/om/Object.vm
db-torque_BRANCH31.work/src/generator/src/templates/om/Object.vm
   --- db-torque_BRANCH31.patched/src/generator/src/templates/om/Object.vm	2003-09-12 00:46:09.000000000
+0200
  -+++ db-torque_BRANCH31.work/src/generator/src/templates/om/Object.vm	2003-10-23 17:42:41.000000000
+0200
  -@@ -1010,6 +1010,19 @@
  ++++ db-torque_BRANCH31.work/src/generator/src/templates/om/Object.vm	2003-10-23 18:12:32.000000000
+0200
  +@@ -1010,15 +1010,28 @@
         */
        public void save() throws $saveException
        {
  @@ -20,8 +20,10 @@
   +    {
      #if ($complexObjectModel)
            save(${table.JavaName}Peer.getMapBuilder()
  -                 .getDatabaseMap().getName());
  -@@ -1018,7 +1031,7 @@
  +-                .getDatabaseMap().getName());
  ++                .getDatabaseMap().getName(), skipIdBroker);
  +   #else
  +         if (isModified())
            {
                if (isNew())
                {
  @@ -30,7 +32,7 @@
                    setNew(false);
                }
                else
  -@@ -1043,6 +1056,25 @@
  +@@ -1043,12 +1056,31 @@
         */
        public void save(String dbName) throws TorqueException
        {
  @@ -56,6 +58,13 @@
            Connection con = null;
      #if ($complexObjectModel)
            try
  +         {
  +             con = Transaction.begin(dbName);
  +-            save(con);
  ++            save(con, skipIdBroker);
  +             Transaction.commit(con);
  +         }
  +         catch(TorqueException e)
   @@ -1065,7 +1097,7 @@
                    if (isNew())
                    {
  @@ -97,6 +106,15 @@
      #if ($complexObjectModel)
            if (!alreadyInSave)
            {
  +@@ -1120,7 +1170,7 @@
  +         #set($i = $velocityCount - 1)
  +         if ($aVarName != null)
  +         {
  +-            ${aVarName}.save(con);
  ++            ${aVarName}.save(con, skipIdBroker);
  +             set$pVars.get($i)($aVarName);
  +         }
  +       #end
   @@ -1133,7 +1183,7 @@
                {
                    if (isNew())
  @@ -108,7 +126,7 @@
                    else
   diff --exclude=CVS -Nurb db-torque_BRANCH31.patched/src/generator/src/templates/om/Peer.vm
db-torque_BRANCH31.work/src/generator/src/templates/om/Peer.vm
   --- db-torque_BRANCH31.patched/src/generator/src/templates/om/Peer.vm	2003-09-12 00:46:09.000000000
+0200
  -+++ db-torque_BRANCH31.work/src/generator/src/templates/om/Peer.vm	2003-10-23 17:39:00.000000000
+0200
  ++++ db-torque_BRANCH31.work/src/generator/src/templates/om/Peer.vm	2003-10-23 18:20:52.000000000
+0200
   @@ -229,8 +229,23 @@
        public static ObjectKey doInsert(Criteria criteria)
            throws TorqueException
  @@ -192,16 +210,16 @@
   +    {
      #if ($table.IdMethod.equals("none") || $table.PrimaryKey.size() == 0)
   -        doInsert(buildCriteria(obj));
  -+        doInsert(buildCriteria(obj), skipIdBroker);
  ++        doInsert(buildCriteria(obj, skipIdBroker), skipIdBroker);
      #else
   -        obj.setPrimaryKey(doInsert(buildCriteria(obj)));
   +        if (skipIdBroker)
   +        {
  -+            doInsert(buildCriteria(obj), skipIdBroker);
  ++            doInsert(buildCriteria(obj, skipIdBroker), skipIdBroker);
   +        }
   +        else
   +        {
  -+            obj.setPrimaryKey(doInsert(buildCriteria(obj), skipIdBroker));
  ++            obj.setPrimaryKey(doInsert(buildCriteria(obj, skipIdBroker), skipIdBroker));
   +        }
      #end
            obj.setNew(false);
  @@ -230,20 +248,40 @@
   +    {
      #if ($table.IdMethod.equals("none") || $table.PrimaryKey.size() == 0)
   -        doInsert(buildCriteria(obj), con);
  -+        doInsert(buildCriteria(obj), con, skipIdBroker);
  ++        doInsert(buildCriteria(obj, skipIdBroker), con, skipIdBroker);
      #else
   -        obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
   +        if (skipIdBroker)
   +        {
  -+            doInsert(buildCriteria(obj), con, skipIdBroker);
  ++            doInsert(buildCriteria(obj, skipIdBroker), con, skipIdBroker);
   +        }
   +        else
   +        {
  -+            obj.setPrimaryKey(doInsert(buildCriteria(obj), con, skipIdBroker));
  ++            obj.setPrimaryKey(doInsert(buildCriteria(obj, skipIdBroker), con, skipIdBroker));
   +        }
      #end
            obj.setNew(false);
            obj.setModified(false);
  +@@ -925,12 +1003,18 @@
  +     /** Build a Criteria object from the data object for this peer */
  +     public static Criteria buildCriteria( $table.JavaName obj )
  +     {
  ++        return buildCriteria(obj, false);
  ++    }
  ++
  ++    /** Build a Criteria object from the data object for this peer */
  ++    public static Criteria buildCriteria( $table.JavaName obj, boolean includePk )
  ++    {
  +         Criteria criteria = new Criteria(DATABASE_NAME);
  +   #foreach ($col in $table.Columns)
  +     #set ( $cfc=$col.JavaName )
  +     #set ( $cup=$col.Name.toUpperCase() )
  +     #if ($col.isPrimaryKey() && !$table.IdMethod.equals("none"))
  +-        if (!obj.isNew())
  ++        if (includePk || !obj.isNew())
  +     #end
  +             criteria.add($cup, obj.get${cfc}());
  +   #end
   diff --exclude=CVS -Nurb db-torque_BRANCH31.patched/src/java/org/apache/torque/om/Persistent.java
db-torque_BRANCH31.work/src/java/org/apache/torque/om/Persistent.java
   --- db-torque_BRANCH31.patched/src/java/org/apache/torque/om/Persistent.java	2002-12-29
19:17:26.000000000 +0100
   +++ db-torque_BRANCH31.work/src/java/org/apache/torque/om/Persistent.java	2003-10-23 18:07:05.000000000
+0200
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message