-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: @Generatedvalue and MySQL
PostPosted: Wed Mar 11, 2009 9:32 am 
Newbie

Joined: Wed Mar 11, 2009 7:15 am
Posts: 13
I can't generate id value in MySQL using @Generatedvalue.
SQLException: no value for 2 parameter in exprection INSERT INTO tab(value, id) values(?, ?)

I tried to use everything what is in commentary

Code:
@Entity   
public class Result {   
@Id   
//@GeneratedValue(strategy = GenerationType.AUTO)   
//@GeneratedValue(strategy=GenerationType.IDENTITY)   
//@SequenceGenerator(name="seq1", sequenceName="HIB_SEQ")   
//@GeneratedValue(strategy=GenerationType.SEQUENCE, senerator="seq1") // no sequentions in MySQL - OK   
//@Column(name = "id", nullable = false)   
Long id;   
... other field, getters, setters   


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 11, 2009 3:21 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Code:
@Id   
@GeneratedValue(strategy=GenerationType.AUTO)


This should work with MySQL and the generated insert should NOT include the 'id' column. Are you sure that you have configured Hibernate to use the correct dialect?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 12, 2009 4:16 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
if you only define @Id without any generators, it means you should assign the PK manually.


Top
 Profile  
 
 Post subject: Re: @Generatedvalue and MySQL
PostPosted: Wed May 13, 2009 12:03 pm 
Newbie

Joined: Wed May 13, 2009 11:52 am
Posts: 2
Did anyone resolve this issue?

@Id
@GeneratedValue(strategy=GenerationType.TABLE)

I am using org.hibernate.dialect.MySQLDialect dialect and I am not able to get it working in MYSQL


Top
 Profile  
 
 Post subject: Re: @Generatedvalue and MySQL resolved
PostPosted: Wed May 13, 2009 12:40 pm 
Newbie

Joined: Wed May 13, 2009 11:52 am
Posts: 2
I was able to resolve this issue after dropping the tables and let hibernate create the tables, you can also create another schema


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.