• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SQLGrammarException

 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is screen shot of my student table
http://3.bp.blogspot.com/_bpkZ2BsqXug/S2byNyT3tWI/AAAAAAAAABw/rv4cL0dy34U/s1600-h/student.GIF

here is a screenshot of my address table
http://4.bp.blogspot.com/_bpkZ2BsqXug/S2byf5z8VdI/AAAAAAAAAB4/MUs24v3Ixtw/s1600-h/address.GIF
 
ishan dave
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am not able to see the images of your tables
 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
student
http://1.bp.blogspot.com/_bpkZ2BsqXug/S2mTSN0RnNI/AAAAAAAAADc/ZU1DuBhMNsc/s1600-h/student.GIF


address
http://1.bp.blogspot.com/_bpkZ2BsqXug/S2mTYxG6vgI/AAAAAAAAADk/XfJOIKm_Fh4/s1600-h/address.GIF

anyway when creating table is it should add address?_id as a forieng key ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic