I have two tables like:
<table name="REQUEST">
<!-- substitution requests (header) -->
<column name="ID" type="INTEGER" required="true"
autoIncrement="true" primaryKey="true"/>
<column name="SRC" type="INTEGER" required="true"/>
<column name="DST" type="INTEGER" required="true"/>
<column name="DATE" size="8" type="VARCHAR" required="true"/>
<column name="NOTE" size="80" type="VARCHAR" required="true"/>
</table>
<table name="DETAILS">
<!-- substitution requests (detail) -->
<column name="ID" type="INTEGER" required="true"
autoIncrement="true" primaryKey="true"/>
<column name="REQUEST" type="INTEGER" required="true"/>
<column name="CODE" type="INTEGER" required="true"/>
<column name="QTY" type="INTEGER" required="true"/>
</table>
which are related via REQUEST.ID = DETAILS.REQUEST
I need to write 1 record in "REQUEST" fallowed by many records in "DETAILS",
try
{
Richieste header = new Request();
header.setSrc( src_code );
header.setDst( dst_code);
header.setDatel( today() );
header.setNote( note );
header.save();
header_id = header.getId().getBigDecimal().intValue();
}
catch (Exception e)
{
context.put("error", "header: " + e.toString());
return;
}
fallowed by code to write records in "DETAILS".
BUT
header_id = header.getId().getBigDecimal().intValue();
fails bacause header.getId() returns null.
the question is:
I must re-read the record just saved (with the immediatly previous
statment), or there is a method to obtain the value of the primary-key just
afer the .save() call?
Re-read the record could be a problem, because the only unique field is
right the ID.
tia, Andrea =8-)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]