• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtime Error when using Annotation on property in JPA

 
Staffan Sandberg
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.
 
Edvins Reisons
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?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
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
Sheriff
Posts: 17278
6
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic