-->
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.  [ 2 posts ] 
Author Message
 Post subject: Cant create fields with reserved names on mysql (but SQL ok)
PostPosted: Wed Mar 03, 2010 7:44 am 
Newbie

Joined: Tue Mar 02, 2010 9:22 am
Posts: 3
Hi all,

I can't create with ibernate a table contating a column named 'delete', it's Asterisk (Open source PBX) needs a field called 'deleted' for voicemail (http://www.voip-info.org/wiki/view/Aste ... +Voicemail)
This SQL works:

CREATE TABLE `voicemail_users` (
`uniqueid` int(11) NOT NULL auto_increment,
....
`delete` varchar(4) NOT NULL default 'no',
....
`stamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`uniqueid`),
KEY `mailbox_context` (`mailbox`,`context`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;

but this class fails to create:

@Entity
@Table(
appliesTo="VoiceMail", indexes=
@Index(
name="mailbox_search_index",
columnNames = {"mailbox","context"}
)
)
public class VoiceMail implements Serializable
{
private static final long serialVersionUID = -4918214058275097969L;
private int uniqueid;
...
private String delete;
...
private String hidefromdir;
}

Shows clasic "Incorrect sintax near delete check your sql manual.."


Top
 Profile  
 
 Post subject: Re: Cant create fields with reserved names on mysql (but SQL ok)
PostPosted: Wed Mar 03, 2010 7:59 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
You'll need to define the column name with backticks:

Code:
@Column(name="`delete`")
private String delete;


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