-->
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.  [ 3 posts ] 
Author Message
 Post subject: list relationship with a where clause
PostPosted: Fri Feb 04, 2005 12:56 pm 
Newbie

Joined: Wed Sep 01, 2004 1:38 pm
Posts: 5
Location: Saint Paul, MN
I am attempting a one-to-many list, where the 'many' table is shared by N other objects. The 'many' table (Action class, t_action table) has a 'type_id' column that specifies a given row's relationship with the other objects. I thought I could avoid the bother of a composite key by handling the typeId specification in the mapping with the optional 'where' clause. However, I'm having trouble formatting the clause to get it to work. I've tried both the sample below, as well as
Code:
where="Action.typeId = 0"
-- both generate similar errors.

What's the trick to this clause? It really looks ideal for my needs.

Thank you!

Hibernate version: 2

Mapping documents:
Code:
<list name="actions" lazy="false" cascade="all" where="t_action.type_id = 0">
    <key column="instance_id"/>
    <index column="idx"/>
    <one-to-many class="node.Action"/>
</list>


Full stack trace of any exception that occurs:
Code:
Caused by: java.sql.SQLException: Base table or view not found,  message from server: "Unknown table 't_action' in where clause"


The generated SQL (show_sql=true):
Code:
select <FIELDS> from t_action actions0_ where actions0_.instance_id=178 and t_action.type_id = 0


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 2:48 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
just use pure SQL condition, only with column

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 3:00 pm 
Newbie

Joined: Wed Sep 01, 2004 1:38 pm
Posts: 5
Location: Saint Paul, MN
Of course.. thank you.

I was so caught up in the relationship between the tables it didn't even occur to me there wasn't actually a join going on, meaning no alias is required.

Sorry for the silly question.


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