db-jdo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Leangen <j...@leangen.net>
Subject Attaching a unique, existing object as a field
Date Fri, 20 Oct 2006 10:01:13 GMT
Hello!

I have a PC container class that holds another PC class as a field, and
the field has a unique id constraint.

When inserting the container class into the DB (it is loaded from an
external source), I first check to see if the field already exists in
the DB and, if so, I attach it to the containing class. For example:

  ContainerClass container = getContainerClass();
  FieldClass unmanagedField = container.getField();
  FieldClass managedField = getFieldFromDb( unmanagedField );
  if( managedField != null )
      container.setField( managedField );
  insertContainerClassIntoDb();


However, I am getting an exception that complains about a duplicate key
constraint.

My assumption was that since the field is already managed, it would not
be re-inserted by the framework.

To accomplish what I'm trying to do, what state do I need to put the PC
field into so it does not get re-inserted?


[BTW, I am currently using JPox as my JDO2 implementation. I was told
there to ask on this list about what the specs say should be done.]

Thank you!



Mime
View raw message