BTW, what's everybody's opinion on changing DataObjectUtils to invoke
"updateId()" method internally, to allow the users to preview the
actual id before commit? I can't see any obvious drawbacks to that.
Andrus
On Jan 15, 2006, at 11:21 AM, Andrus Adamchik wrote:
> public int getId() {
> ObjectId oid = getObjectId();
>
> if(oid.isTemporary() && !id.isReplacementIdAttached()) {
> // generate id here
> updateId();
> }
>
> // now we can safely use DataObjectUtils
> return DataObjectUtils.intPKForObject(this);
> }
>
> void updateId() {
> DbEntity entity = getDataContext().getEntityResolver
> ().lookupDbEntity(this);
> DataNode node = getDataContext().lookupDataNode(entity.getDataMap
> ());
>
> Object pk = node.getAdapter().getPkGenerator
> ().generatePkForDbEntity(node, entity);
> getObjectId().getReplacementIdMap().put
> ("<actual_pk_attribute_name>", pk);
> }
>
> Andrus
This archive was generated by hypermail 2.0.0 : Sun Jan 15 2006 - 11:26:57 EST