Changing field type goes well. But changing returning type in "get" method (into Integer) or changing internal parameter (explicit) in "set" method causes that my Eclipse IDE can't recognize primary key field. I get warning mark at @Entity annotation with tip "The entity has no primary key attribute defined"
Code looks like this:
If I remove Integer types from methods the Eclipse warning disappears.
But during deployment server throws Exceptions for that JPA entity class.
What is wrong with taht Integer type?
I can't find in documentation statement that Integer can't be used for primary key field.
This should work. Eclipse could be an ide local issue. Please provide what errors you are facing during deployment.
Also what JPA implementation you are using?
Right now I have done some check. I exported this whole project to EAR file and deployed it manually on the server and it works. I should have done it earlier : ) but changing PK type from Integer into int seemed for me faster solution than looking for a cause of the problem.
So the problem is Eclipse.
Cesar Sportore wrote:But the @Id annotation only works for variables of the Long type, isn't it?
No, from the java doc for Id
Id annotation is applied should be one of the following types: any Java primitive type; any primitive wrapper type; String; java.util.Date; java.sql.Date; java.math.BigDecimal; java.math.BigInteger.