Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Runtime Error when using Annotation on property in JPA  RSS feed

 
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
IntelliJ IDE Mac 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
IntelliJ IDE Mac 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!
 
What are you doing? You are supposed to be reading this tiny ad!
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!