java - Is mapping of an @Embeddable through a wrapper @Entity possible? -
i building persistence layer number of data classes can not change. these classes have no id property/field makes them ill suited being used in orm.
best case scenario me have been sort of auto-generated ids present inside database set objects in relation each other. sadly not seem possible using jpa apis.
since above approach did not work out, decided on trying use simple wrapper @entity objects so:
@entity public class thirdpartyobjectwrapper { @id private long id; @embedded private thirdpartyobject mythirdpartyobject; }
this approach works out nicely in database, having problems getting object out of wrapper , place inside third party object.
public class anotherthirdpartyobject { private thirdpartyobject object; //actually in many-to-one-relationship }
because third party objects i'm mapping them through orm.xml file defining relationships there. @ point in time relationship mapping looks so:
<many-to-one name="object" target-entity="thirdpartyobjectwrapper"/>
but setup hibernate tries insert thirdpartyobjectwrapper.id
anotherthirdpartyobject.object
field, fails.
my question is:
trying possible?
Comments
Post a Comment