Reputation: 2151
I am working with JPA application.The JPA annotations are applied on Getter methods and its working but when I am trying to apply the annotations on fields then compiler generate the error. I want to apply annotations on fields.
@Entity
@Table(name="TB_DEMO",query="select q from TB_DEMO q")
public class Demo extends DomainRoot{
@Column(name="VAR_COUNT")
private int varCount;
public int getCount(){
return this.varCount;
}
public void setCount(int count){
this.varCount=count;
}
}
Error: org.springframeowork.dao.InvalidDataResourceUsageException: Could not prepare statement
org.h2.jdbc.JdbcSQLException: Column "QSXXXXXXXX_.VARCOUNT" not found
Upvotes: 0
Views: 566
Reputation: 585
The persistence provider isn't consider your field attributes why DomainRoot or application default access using mapping by Property (Annotations on gets) and you trying to use mapping by Field(Annotations on Fields).
The specifications say that in this case (Inhritance), the comportament is unpredictable.
For your example, increase @Access(AccessType.FIELD) on class level or simply use the same access level on whole class hierarchy without declare @Access Annotations.
Upvotes: 1