• 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: 17309
11
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.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!