• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Runtime Error when using Annotation on property in JPA

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When making an Entity in JPA I have to put the Annotations on the getter-methods to get the application working. When I try to move any Annotation from the getter-method to the corresponding property I always get a runtimeError.

Are there any restrictions when to put the Annotation directly on the property? Anyone else experienced this?

This works fine:


But this code:


..always generates this runtime error on my Websphere 6.1 instance:


[2008-05-02 09:10:10:730 CEST] 0000001e JPAPUnitInfo E CWWJP0015E: An error occurred in the org.hibernate.ejb.HibernatePersistence persistence provider when it attempted to create the container entity manager factory for the databasen persistence unit. The following error occurred: [PersistenceUnit: databasen] Unable to build EntityManagerFactory
[2008-05-02 09:10:10:730 CEST] 0000001e JPAPUnitInfo E CWWJP0009E: The server cannot create an EntityManangerFactory factory for the databasen persistent unit from the org.hibernate.ejb.HibernatePersistence provider in file:/C:/dev/workspace_EJB3-test/EJB3EJB/bin/ module.
 
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.





What happens when you make the field public?
 
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
private should be fine, but where is your @Entity above the class?

Mark
 
Mark Spritzler
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, where you put your @Id determines whether all the annotations need to be on the property or the getters.

So if you put @Id on the property, then all your annotations must be on the properties.

Mark
 
Staffan Sandberg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

When i put all my annotions on the properties it works!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!