aspose file tools*
The moose likes Object Relational Mapping and the fly likes Missing left parenthesis Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Missing left parenthesis" Watch "Missing left parenthesis" New topic
Author

Missing left parenthesis

Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
Hi,
Today i was trying to check whether i've understood hibernate concepts or not...

So i wrote some code example as Teacher Student example....

And yes there is joins concept to be checked in this example...

There is many to one relationship between Teacher and student respectively....

When i was done with my code writing... I tried running it....

Then there was this error "Missing left parenthesis"

Following is my code.... Please check and tell me where did i've gone wrong....


mySchoolApp.java




Teacher.java



Student.java



hibernate.hbm.xml



teacher.hbm.xml


Table Description
Student
ROLLNO,SNAME,CLASS,TSUBJECT,TID{Foreign key}

Teacher
TID{Primary key},TNAME,MSUBJECT



Please go through it..... And then we can discuss....


Thanks,
Aditya Kanitkar.


Christian Dillinger
Ranch Hand

Joined: Jul 20, 2009
Posts: 189
Please post the SQL thats generated by hibernate.
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
This is the query generated by Hibernate


Hibernate: select student0_.rollno as rollno0_, teacher1_.tid as tid1_, student0_.sname as sname1_0_, student0_.class as class1_0_, student0_.tsubject as tsubject1_0_, student0_.tid as tid1_0_, teacher1_.tname as tname0_1_, teacher1_.msubject as msubject0_1_ from student student0_, table teacher1_ where student0_.tid=teacher1_.tid
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
It's probably not a good idea to name a table "table"; try "teacher" instead.
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
Lester Burnham wrote:It's probably not a good idea to name a table "table"; try "teacher" instead.


But i have not given that name to any table....
I've only two tables TEACHER and STUDENT....

I know that there is something wrong with the query
where we have to give alias to a table.....


I dont know why its creating like this......

Hibernate: select student0_.rollno as rollno0_, teacher1_.tid as tid1_, student0_.sname as sname1_0_, student0_.class as class1_0_, student0_.tsubject as tsubject1_0_, student0_.tid as tid1_0_, teacher1_.tname as tname0_1_, teacher1_.msubject as msubject0_1_ from student student0_, table teacher1_ where student0_.tid=teacher1_.tid
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
But i have not given that name to any table....

Isn't that what this does:
<class name="com.test.school.Teacher" table="table">
<id name="tid" type="int" column="tid" />
<property name="tname" column="tname" />
<property name="msubject" column="msubject" />
</class>
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
Oh my God.....

Why didnt saw that before....??

Damn....


Thanks to you guys.....

 
Don't get me started about those stupid light bulbs.
 
subject: Missing left parenthesis