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

List:       turbine-torque-user
Subject:    RE: Specifying the PK manually (Torque 3.1)
From:       "Greg Monroe" <Greg.Monroe () DukeCE ! com>
Date:       2005-11-01 15:32:21
Message-ID: 0EBA2D5D58A98C4AAFBF2ACB6E625A260C1932 () dukece-mail2 ! dukece ! com
[Download RAW message or body]

A quick thought on this is that there are also various DB 
specific issues to deal with if the PK is defined as an 
autoincrement field.  For example, MS SQL won't let you do 
an insert with an "Identity" field value unless you turn 
off autoincrement on the table (remember to turn it back 
on!).  MySQL has the same behavious unless you to use 
it's REPLACE operation.  

Unfortunately, it's a case of autoincrement being a commonly 
desired feature but not backed by a common standard. IMHO, 
I'd say it's beyond the scope of Torque to try to create 
it's own "autoincrement" standard that has to be supported/fit 
into the various DB implimentations.  It would be nice, but 
a devil to maintain across new DB versions, etc. 

> -----Original Message-----
> From: Thomas Fischer [mailto:tfischer@apache.org] 
> 
> 
> Hi,
> 
> From a simple point of view, the behavoiur you describe is 
> not what one 
> would want.
> However, I am of the opinion that this should not be changed in the 
> forthcoming 3.2 release, because it would break backwards 
> compatibility.
> 
> Internally, doInsert calls the generated method 
> BaseAuthorPeer.buildCriteria(), which 
> inserts the Id only if the author is not new. The 
> buildCriteria() method 
> is also called from the doUpdate methods, and also in the 
> Manager class, 
> and cannot be changed easily. Of course, one can create Yet 
> Another Method 
> to accomplish this, making the classes even more complicated, which I 
> would want to avoid.
> 
> If you want, open a Bug report in scarab, it might be 
> considered in a post 
> 3.2 release (also depends on what the other deveolpers think about it)
> 
> Thomas
> 
> On Fri, 21 Oct 2005, Vitzethum, Daniel wrote:
> 
> > 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
> > 
> > 
> 

Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are confidential \
communication or may otherwise be privileged or confidential and are intended solely \
for the individual or entity to whom they are addressed.  If you are not the intended \
recipient you may not rely on the contents of this email or any attachments, and we \
ask that you  please not read, copy or retransmit this communication, but reply to \
the sender and destroy the email, its contents, and all copies thereof immediately.  \
Any unauthorized dissemination, distribution or copying of this communication is \
strictly prohibited.



---------------------------------------------------------------------
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