• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Hibernate @GeneratedValue problem

 
Greenhorn
Posts: 13
  • 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
 
Ranch Hand
Posts: 162
Hibernate Spring Java
  • 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
  • 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 Spring Java
  • 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
  • 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.......
 
Greenhorn
Posts: 1
  • 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
 
The moustache of a titan! The ad of a flea:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic