• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JPA Entity not recognized as a known entity

 
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am writing a JPA code wherein I try to read/write some entities in my database through JPA. One funny thing that I came across was when I am reading an entity for the first time( the entity record is inserted at the backend), JPA throws exception as "Entity name ABC not recognized as a known entity. Perhaps you meant XYZ. Known entity names [XYZ].

Now the difference between ABC and XYZ is that XYZ was inserted through JPA and then read.
When I do the same thing with ABC, it starts recognizing it, which means all the JPA configurations with respect to ABC are correct. Any ideas?
 
Prajakta Acharya
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone throw some light on this?
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you using for your JPA provider? Can you post the full stack trace? Are your entities defined in your persistence XML fully qualified?
 
Prajakta Acharya
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using EJB3.0. The entities are annotated hence not defined in persistence.xml.

I could not reproduce this exception when I created a new entity at back end and inserted entry to it.
So not sure about the cause...
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The spec still expects them in the persistence.xml.

You can read this thread

http://stackoverflow.com/questions/1780341/do-i-need-class-elements-in-persistence-xml
or here also
http://docs.oracle.com/cd/E19798-01/821-1841/bnbpy/index.html


Also Hibernate for example has its own @Entity annotation and I have seen people inadvertently use it instead of the one coming out of javax.persistence. Having the wrong import will also cause issues.

 
Prajakta Acharya
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bill for your inputs. I will look at the links.
 
reply
    Bookmark Topic Watch Topic
  • New Topic