You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Fabio Daprile <fa...@wuerth.it> on 2002/01/10 10:31:57 UTC
Can't retrieve the primary key after an insert of a new record!
I have the following code... after the save (which is successful) I cannot
get back the key (which I know was made and used because I see it in the DB)
the same results if the primary key method is idbroker or auto_increment in
the Map file... I am using mysql..
here is my code;
_ticket = new Tickets();
_ticket.setEffectiveid("1");
_ticket.setProjectid(String.valueOf(_projectId));
_ticket.setQueueid(_queue.getId().toString());
_ticket.setOwnerid(_user.getId().toString());
_ticket.setSubject(_subject);
_ticket.setDescription(_description.getBytes());
_ticket.setArea(_area);
_ticket.setHowtoreproduce(_howToReproduce.getBytes());
_ticket.setPriority(_priority);
_ticket.setRaisedrefversion(_raisedVersion);
_ticket.setFixedrefversion("");
_ticket.setStatus("new");
_ticket.setTimeestimated(0);
_ticket.setTimeworked(0);
_ticket.setStartedtimestamp(new Date(0));
_ticket.setDuetimestamp(new Date(0));
_ticket.setResolvedtimestamp(new Date(0));
_ticket.setLastupdatedbyid(_user.getId().toString());
_ticket.setLastupdatetimestamp(Calendar.getInstance().getTime());
_ticket.setCreatorid(_user.getId().toString());
_ticket.setCreatedtimestamp(Calendar.getInstance().getTime());
_ticket.setDisabled(0);
_ticket.setNew(true);
_ticket.save();
System.out.println(_ticket.getPrimaryKeyAsInt()); <always null>
or System.out.println(_ticket.getId().toString());
<always null>
Can you help me?
--
Würth Phoenix Srl
Via Kravogl 4, I-39100 Bolzano
Tel: +39 0471/564111
Fax: +39 0471/564122
mailto:fabio.daprile@wuerth-phoenix.com
http://www.wuerth-phoenix.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Can't retrieve the primary key after an insert of a new record!
Posted by Fabio Daprile <fa...@wuerth.it>.
Thx Guys,
iI've added to my schema the idmethod as idbroker
<table name="Tickets" skipSql="false" idMethod="idbroker">
and everything works correctly.
Bye!
Fabio
--
Würth Phoenix Srl
Via Kravogl 4, I-39100 Bolzano
Tel: +39 0471/564111
Fax: +39 0471/564122
mailto:fabio.daprile@wuerth-phoenix.com
http://www.wuerth-phoenix.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>