Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLGrammarException

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my config file


here is my main class


here is student class


here is address class

here is exception

 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Grammar is usually a problem with the mapping.

Can you get an example to work that doesn't use an association? Maybe you should start with something a bit easier.

-Cameron McKenzie
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to run one to one example.
Also i was able to run many to one mapping without annotation.
This is with many to one mapping with annotation.
I need to study annotation also.
when i am running this example without annotation it works.
can you please tell me where is the error?

here is the site where is Refer

without annotation(Works withour error)
http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-many-to-one-1.html

with annotation(still error)
http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-many-to-one-using-annotations-1.html
 
ishan dave
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

@ManyToOne(cascade = CascadeType.ALL)
public Address getStudentAddress() {
return this.studentAddress;
}

please put the join column name like

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name="ADDRESS_ID")
public Address getStudentAddress() {
return this.studentAddress;
}

thank you,
ishaan
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i change my student clas

still i get this error?



i think this may be database error?
if there is @GeneratedValue in id filed is it must to make default value for clume value?
 
ishan dave
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
may know your DDL of both the tables.

Do you have Address_id column in your Student tale ?
if not then please put that.

and please make sure that you checked the auto-increment on in both your tables in mysql.


thank you,
ishaan
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I manually created the tables.
here is a site witch i use.
http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-many-to-one-using-annotations-1.html

there is a address columne in student table.
can you send me the DDL please?
i didn't use DDl .i make tables manually.
how to check auto-increment option?
 
Christian Dillinger
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You talk to your MySQL in a language only you and MySQL understand?!? Quite cool... If you don't know what he means with "DDL", you could ask. He wants you to show us, how your table looks like. That means table name, column names and column types. Maybe you don't a column named ADRESS_ID, because thats what the error is about.
 
Samanthi perera
Ranch Hand
Posts: 510
 
ishan dave
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not able to see the images of your tables
 
Christian Dillinger
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you switch to the mobile version of the forum you see the complete link.
 
Samanthi perera
Ranch Hand
Posts: 510
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic