0

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

6
  • What is the error? How are you compiling? Commented Dec 15, 2017 at 20:28
  • JDBCSQLException is not a compilation error. Post rather the exception. Commented Dec 15, 2017 at 20:29
  • Yes it is. Let me post the error Commented Dec 15, 2017 at 20:36
  • post your complete entity class definition. Commented Dec 15, 2017 at 20:41
  • it is working with getter methods but not working with fields Commented Dec 15, 2017 at 20:45

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.