-->
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.  [ 1 post ] 
Author Message
 Post subject: Generating ID using GenerationType.TABLE and MySQL
PostPosted: Wed May 06, 2009 3:53 pm 
Newbie

Joined: Thu Feb 19, 2009 12:24 pm
Posts: 14
Hello,

I am trying to generate IDs using GenerationType.TABLE and MySQL but encounters some problem.

Since it may matter I have defined the connection properties in my hibernate.cfg.xml file.

Here is my code:

Code:
@Id
   @GeneratedValue(strategy=GenerationType.TABLE, generator="EMP_GEN")
   @TableGenerator(name="EMP_GEN", table="GENERATOR_TABLE", pkColumnName = "key", valueColumnName = "hi", pkColumnValue="value", allocationSize=10)   
   public Long getOrderNumber(){
      return orderNumber;
   }


And my Error:

Code:
ERROR: could not read or init a hi value
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = 'value' for update' at line 1
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)


Does anyone know what the problem could be? And where can I get good references for how @TableGenerator works?

Thank you in advance!

Regards,
Niklas

_________________
Beginners must also learn!


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

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.