-->
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.  [ 9 posts ] 
Author Message
 Post subject: one column name is values, how to handle this?any1 know? thx
PostPosted: Mon Sep 19, 2005 11:22 pm 
Newbie

Joined: Mon Sep 19, 2005 11:11 pm
Posts: 7
i have a column named values which is the preserved word in sql syntax.
when use jdbc, i can handle this by specifying the table name with the values column(tablename.values). but in Hibernate i cannot do this.
does any1 know how to solve this problem? the database shouldn't be changed.
thx very much


Top
 Profile  
 
 Post subject: Re: one column name is values, how to handle this?any1 know?
PostPosted: Tue Sep 20, 2005 12:43 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
kingwell wrote:
when use jdbc, i can handle this by specifying the table name with the values column(tablename.values). but in Hibernate i cannot do this.

You can directly use SQL within Hibernate (SQLQuery or even, if nothing else helps, get the DB connection and work with JDBC), so you should be able to solve your problem.

Shouldn't this hint be helpful, provide your concrete example/code.

Erik


Top
 Profile  
 
 Post subject: Re: one column name is values, how to handle this?any1 know?
PostPosted: Tue Sep 20, 2005 1:13 am 
Newbie

Joined: Mon Sep 19, 2005 11:11 pm
Posts: 7
ErikFK wrote:
kingwell wrote:
when use jdbc, i can handle this by specifying the table name with the values column(tablename.values). but in Hibernate i cannot do this.

You can directly use SQL within Hibernate (SQLQuery or even, if nothing else helps, get the DB connection and work with JDBC), so you should be able to solve your problem.

Shouldn't this hint be helpful, provide your concrete example/code.

Erik


i don't think so. if doing in this way, OR mapping loses its meanning.
for example, i have one table named NUMBER, with two columns inside( id, and values)
when i want to insert a new record, the sql command will be insert into number(id, NUMBER.values) values('1','100')
but in hibernate how can you handle this, when i save one number instance, the generated sql is insert into number(id, values) values('1','100')

thank u very much for help


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 1:36 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
Would something like
Code:
<class name="Number" table="NUMBER">
   <id name="id" column="ITEMS_ID"/>
   <property name="values" column="NUMBER.VALUES"/>
</class>

be of any help?

Erik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 1:41 am 
Newbie

Joined: Mon Sep 19, 2005 11:11 pm
Posts: 7
ErikFK wrote:
Would something like
Code:
<class name="Number" table="NUMBER">
   <id name="id" column="ITEMS_ID"/>
   <property name="values" column="NUMBER.VALUES"/>
</class>

be of any help?

Erik

no, i have tried this before
column="NUMBER.VALUES" makes hibernate throw no column found exception
but anyway, thanks for ur help


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 3:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look for how to quote sql identifiers in the ref documentation.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 4:04 am 
Newbie

Joined: Mon Sep 19, 2005 11:11 pm
Posts: 7
max wrote:
look for how to quote sql identifiers in the ref documentation.

hi max, thanks for you help, but i cannot find how to solve this problem from the ref documentation, will you plz show me? thankx very much


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 4:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
http://www.hibernate.org/hib_docs/v3/re ... dentifiers

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 4:08 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
kingwell wrote:
max wrote:
look for how to quote sql identifiers in the ref documentation.

hi max, thanks for you help, but i cannot find how to solve this problem from the ref documentation, will you plz show me? thankx very much

Which version of Hibernate are you using? Look in documentation of 3.0.5, chapter 5.3 (was 6.3 in 2.1.6)

Erik


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