You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Guido Sohne <ca...@yahoo.com> on 2001/08/24 18:59:05 UTC
primary key null after object.save()
I have a class called Level in which I have a createLevel method ...
public static Level createLevel(Level parent, String name)
{
l.setName(name);
l.setParentid(parent.getPrimaryKey());
l.save();
return l;
}
The problem I have is when I pass this newly created level and try to
create another level with this level as its parent.
After l.save() is called, I log the following
l.getRowid() <--- shows null
l.getPrimaryKey() <--- shows null (rowid equivalent to primary key)
l.getPrimaryKeyAsInt() <--- shows -1
I also tried changing BaseLevelPeer.java so that in the function with
signature void doInsert(Level l, DbCon dc),
doInsert(buildCriteria(l), dc);
obj.setNew(false);
is replaced by
ObjectKey ok = doInsert(buildCriteria(l), dc);
l.setPrimaryKey(ok);
obj.setNew(false);
I even tried
Criteria c = new Criteria();
c.remove(LevelPeer.ROWID);
ObjectKey ok = doInsert(c, dc);
l.setPrimaryKey(ok);
obj.setNew(false);
So how does one get the primary key of a newly created object ?
I am using TDK 2.1 final ...
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org