-->
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.  [ 4 posts ] 
Author Message
 Post subject: Is 'key' a reserved word?
PostPosted: Fri Sep 18, 2009 2:18 am 
Newbie

Joined: Mon Sep 14, 2009 2:04 pm
Posts: 4
I have a class like below,

@Entity
public class Configuration {
@Id
@Column(length=64)
private String key;

@Column(length=255)
private String value;
...
}

Hibernate will not create table for me with hbm2ddl.auto=update.

However, if I rename 'key' to something else, for example 'name', the table will be created correctly.

Interesting...


Top
 Profile  
 
 Post subject: Re: Is 'key' a reserved word?
PostPosted: Fri Sep 18, 2009 7:29 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Which database are you using?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Is 'key' a reserved word?
PostPosted: Wed Sep 23, 2009 2:23 pm 
Newbie

Joined: Mon Sep 14, 2009 2:04 pm
Posts: 4
Mysql.


Top
 Profile  
 
 Post subject: Re: Is 'key' a reserved word?
PostPosted: Thu Sep 24, 2009 3:58 am 
Newbie

Joined: Wed Jun 21, 2006 9:48 am
Posts: 12
Location: Germering
Key is a reserved word in SQL as it is a single word i.e. it is Primary key and not primarykey!

If you like to name the column "key" try this

@Entity
public class Configuration {
@Id
@Column(name = "\"key\"", length=64)
private String key;

@Column(length=255)
private String value;
...
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.