File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate @GeneratedValue problem

 
subhanair girish
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using mysql,hibernate ,spring



Executing above code doesnot work.
Exception listing are


please help me in this, the problem is with generation_type, but I cannot correct it.
please..it's urgent
 
Kuladip Yadav
Ranch Hand
Posts: 162
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'library.login' doesn't exist

Your table 'login' is not created in database
and you are trying to save in it !!!
 
subhanair girish
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The table 'login' gets created if I am not writing @GeneratedValue in the @id field.

I am using mysql database that can take only GenerationType=IDENTITY to start the autoincrement feature.
 
Kuladip Yadav
Ranch Hand
Posts: 162
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


use userid as Long or Interger it will work.
May be For String GeneratedValue will not work
Tannking you
 
subhanair girish
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot . Its working perfectly now...
Thanks thanks

I do have one more issue.Its about setting foreign key in the table. I tried many ways, but it's not working.
I have two table

partner( idno(pk) , verifno)
user(userid(pk), idno(fk),username)

How to set foreignkey relation in the user table.





Please help me in this.......
 
Bogdan Nechyporenko
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should make your @Id field with Long type or remove @GeneratedValue. Because GeneratedValue you could write only in Long type fields
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic