JPA exception: Object: … is not a known entity type

后端 未结 11 533

I\'m new to JPA and I\'m having problems with the autogeneration of primary key values.

I have the following entity:

package jpatest.entities;

impor         


        
相关标签:
11条回答
  • 2020-12-10 03:00

    Check the class output folder of eclipse, sometimes you change the xml and it was not updated.

    0 讨论(0)
  • 2020-12-10 03:02

    I ran into this same problem using NetBeans IDE 6.9.

    Apparently, this is a known issue. See http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_101:_20100218:_Descriptor.javaClass_is_null_on_a_container_EM_for_a_specific_case. Also see http://netbeans.org/bugzilla/show_bug.cgi?id=181068.

    I added the last line below to persistence.xml and it fixed it for me.

    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <!-- Add the following to work around exception issue -->
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    
    0 讨论(0)
  • 2020-12-10 03:02

    As far as I know, whenever I get this error, I just re-start glassfish. Works everytime.

    0 讨论(0)
  • 2020-12-10 03:03

    if you are only getting this error in junit

    try adding this in persistence.xml

    <jar-file>file:../classes</jar-file>
    
    0 讨论(0)
  • 2020-12-10 03:04

    The combination of deployment from within NetBeans 8.2 on Glassfish 4.1 on a Maven project with the "Debug" function of a project can cause an outdated version to be re-deployed (unclear where the fault lies).

    Stop GlassFish, delete [glassfish base]/glassfish/domains/[domain name]/generated/, restart and redeploy.

    0 讨论(0)
  • 2020-12-10 03:07

    I ran into the same exception, when deploying web applications to GlassFish v3 (which uses EclipseLink as its JPA provider). I am not sure it's the same scenario as above - but the explanation for this bug in my case might help others :-) - turns out there's a bug in EclipseLink, when running under OSGi (which is the case in GlassFish), which leads EclipseLink to hold on to an "old" version of the entity class when re-deploying, resulting in this exception. The bug report is here.

    0 讨论(0)
提交回复
热议问题