[prev in list] [next in list] [prev in thread] [next in thread] 

List:       turbine-torque-user
Subject:    Specifying the PK manually (Torque 3.1)
From:       "Vitzethum, Daniel" <Daniel.Vitzethum () gigatronik ! com>
Date:       2005-10-21 11:29:39
Message-ID: 5EE5137D79A3CA45970354F512B3F3E334A1AC () m-ex1 ! gt ! local
[Download RAW message or body]

Hello all,

the following behavior just surprised me a bit: ;-)

When creating a new instance of an OM object, setting the pk maually and saving
it, the PK will be ignored. If a id method is specified, the pk will be retrieved from
there (e.g. Oracle Sequence).

When specifying the values via a Criteria object, I can set the PK and it will be
considered when saving. If the PK already exits, the DB throws an error, certainly.

Here's the example code:

  // when saving an author, pk is ignored
  Author a1 = new Author();
  a1.setAuthorId(999);
  a1.setLastName("Knallinger");
  a1.setFirstName("Ingnoratio");
  AuthorPeer.doInsert(a1);
        
  // by criteria, pk will be used
  Criteria c = new Criteria();
  c.add(AuthorPeer.AUTHOR_ID, 999);
  c.add(AuthorPeer.LAST_NAME, "Knüllinger");
  c.add(AuthorPeer.FIRST_NAME, "Karl");
  AuthorPeer.doInsert(c);

Is this behavior considered to be correct (what is the background, then), or not?


Daniel

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic