jpa error uses a non-entity [class ch.printsoft.mailhouse.usermgr.entity.Department] as target entity in the relationship attribute

前端 未结 8 613
北海茫月
北海茫月 2020-12-18 19:17

I try to persist my Department and Mandator classes to hsqhldb but it gives this error.

Exception Description: [class ch.printsoft.         


        
相关标签:
8条回答
  • 2020-12-18 19:56

    Remove mappedBy from @OneToMany annotations from Mandator class

    Check if all related classes are mapped as @Entity. Department class has @ManyToMany relation to DocumentUser. Provide the listing of DocumentUser class

    0 讨论(0)
  • 2020-12-18 20:00

    Ensure you have both classes are defined in your tag of persistence.xml which you tag are using. At time of persistence the entity into DB application finds the entity information from persistence.xml file. If mapping entity is not found application throw this exception.

    Please include your persistence.xml

    Example: persistence.xml :-

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">   
        <persistence-unit name="mapping_unit">
            <class>ch.printsoft.mailhouse.usermgr.entity.Mandator </class>
            <class>ch.printsoft.mailhouse.usermgr.entity.Department</class>
            ...
            <properties>
                <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
                <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/practice" />
                <property name="javax.persistence.jdbc.user" value="root" />
                <property name="javax.persistence.jdbc.password" value="root" />
                <property name="eclipselink.logging.level" value="SEVERE" />
                <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
            </properties>
        </persistence-unit>
        
    </persistence>
    
    0 讨论(0)
提交回复
热议问题