Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query

 
Gabriela Rios
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have a question/problem. I have a class with my User object. If I only have the columns as variables, everything works as expected. If I add another variable that is not in the database, I get "Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query". I thought I could add the other variables without mapping them to the table (cardNumber, balance). I was wrong How can I add them to my class? Thanks.


 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default all properties are mapped with Annotations. So if you have a property that is not in the database you have to annotate it with @Transient.

Moving this to the ORM forum. This is not Spring related.

Mark
 
Gabriela Rios
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! My bad. I'll be more careful next time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic