Howdy, all. I'm wondering what the best practice is for the following use case:
I have a handful of entity classes, one of which is a Unit (such as "kilogram") which has an auto-generated UID field. Each individual instance of Unit ("kilogram", "second", "ampere", etc) can and will be used by multiple instances of the other entity classes. The problem arises after I persist one of the unit instances (such as "kilogram") and it is assigned a primary key field generated by the container. From that point forward, each other object that refers to that specific Unit instance gives me trouble when I try to persist it, because it already has a nonzero UID field value. Ideally, I do not want to have more than one "kilogram" record in the "Unit" table. Is there a common practice to tell the persistence container to "apply the persist cascade of the holding object to this field, unless the data represented by the field already exists in the database, in which case don't cascade--just reference the UID of that instance"? If the question isn't clear, I can provide sample code. If you want to punt to the OpenJPA list, that's also acceptable. Cheers, -- Alex