Search code examples
javajpapersistencejax-ws

incorrect table linkage?


Caused by: <openjpa-2.2.3-SNAPSHOT-r422266:1677238 fatal user error> org.apache.openjpa.persistence.ArgumentException: In "main.java.jpa.OepRole.oepUsers" it is declared that it is mapped to "OepRole", but it is not a field of the associated type.

            at org.apache.openjpa.meta.FieldMetaData.getMappedByMetaData(FieldMetaData.java:867)

            at org.apache.openjpa.jdbc.meta.FieldMapping.getMappedByMapping(FieldMapping.java:447)

            at org.apache.openjpa.jdbc.meta.MappingRepository.useInverseKeyMapping(MappingRepository.java:1047)

            .....

            at org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:997)

            at com.ibm.ws.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:160)

            at com.ibm.ws.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:139)

            at com.ibm.ws.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:50)

            at ru.soa.service.sudir.itdi.smallsystem_generic_webservice_connector._1_0.GenericAccountManagementSoapBindingImpl.getAccountList(GenericAccountManagementSoapBindingImpl.java:684)

I suppose the problem in tables linkage. I suppose the problem in tables linkage. Here is how i tryed to link my tables.

It OepRole table
//bi-directional many-to-one association to OepUser
@OneToMany(mappedBy="OepRole")
private List<OepUser> oepUsers;


It OepUser table 
//bi-directional many-to-one association to OepRole
@ManyToOne()
@JoinColumn(name="USER_ROLE_ID")
private OepRole oepRole;

i tried to change mappedBy,tried all illogical and logical moves, but it doesn't help me. What i do wrong?


Solution

  • try this, the mappedBy name OepRole and variable name in another entity variable has to match.

    @OneToMany(mappedBy="oepRole")
    private List<OepUser> oepUsers;
    
    @ManyToOne()
    @JoinColumn(name="USER_ROLE_ID",nullable=false)
    private OepRole oepRole;