eclipselink - JPA: several relations -
i have trouble jpa , right annotations , tried lot of annotations , combinations @joincolumn, mappedby , on, still errors. use eclipselink (jpa 2.1).
i have owner class store:
@entity public class store extends baseentity { @notnull private string name; @notnull @onetomany private list<price> listprices; @notnull @onetomany private list<businesshours> listbusinesshours; @notnull @onetoone @joincolumn(name="store_id") private pointcoordinates pointcoordinates; ... }
this class pointcoordinates:
@entity public class pointcoordinates extends baseentity { @notnull private float long; @notnull private float lat; @onetoone(mappedby="pointcoordinates") private store store; ... }
and 1 of "@onetomany" classes of 'store':
@entity public class businesshours extends baseentity { private boolean holiday; @manytoone private store store; ... }
i thought should work, because 'store' owner of 'pointcoordinates' have annotate attribute private store store
@onetoone(mappedby="pointcoordinates")
, on other side have annotate attribute private pointcoordinates pointcoordinates
@joincolumn(name="store_id")
still same error:
error message on glassfish 4.0
caused by: javax.persistence.persistenceexception: exception [eclipselink-4002] (eclipse persistence services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.databaseexception internal exception: java.sql.sqlexception: fehler beim zuweisen einer verbindung. ursache: java.lang.illegalstateexception: lokale transaktion enthält bereits 1 nicht-xa-ressource: weitere ressourcen können nicht hinzugefügt werden. error code: 0 call: insert pointcoordinates (id, lat, long) values (?, ?, ?) bind => [3 parameters bound]
error message on glassfish 3.1.2.2 (english)
exception [eclipselink-4002] (eclipse persistence services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.databaseexception internal exception: java.sql.sqlexception: fehler beim zuweisen einer verbindung. ursache: java.lang.illegalstateexception: local transaction has 1 non-xa resource: cannot add more resources. error code: 0 call: insert pointcoordinates (id, lat, long) values (?, ?, ?) bind => [3 parameters bound] query: insertobjectquery(com.company.entities.output.rest.pointcoordinates@3a6a03ea)
i have answer! got error because annotated pointcoordinates "@notnull". wrong, should use attribute "optional".
the reason other error got "local transaction has 1 non-xa resource: cannot add more resources" happened because had several different transactions several persistence units.
Comments
Post a Comment