-->
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: any way to use entity attribute in where attribute of set?
PostPosted: Thu Mar 11, 2004 11:36 am 
Beginner
Beginner

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 20
Hi,

Is there a way to refer to entity attribute in set's where attribute?

I have a class mapping contains the following:
Code:
<property name="entityType" type="string" length="50"></property>
<map name="attachments" batch-size="1" cascade="delete-orphan"
   inverse="true" [color=red]where="parentType=:entityType[/color]">
   <key column="parentId"></key>
   <index column="fileName" type="string" length="50"></index>
   <one-to-many class="AttachmentInfo" />
</map>


Hibernate generates the following message:
Code:
select ... from ATTACHMENTS attachment0_ where attachment0_.parentId=? and attachment0_.parentType=:entityType

net.sf.hibernate.util.JDBCExceptionReporter  SQL Error: 1008, SQLState: 72000
net.sf.hibernate.util.JDBCExceptionReporter  ORA-01008: not all variables bound

net.sf.hibernate.util.JDBCExceptionReporter  SQL Error: 1008, SQLState: 72000
net.sf.hibernate.util.JDBCExceptionReporter  ORA-01008: not all variables bound

net.sf.hibernate.util.JDBCExceptionReporter  could not initialize collection: [com.celestica.sea.model.Issue.attachments#1]
net.sf.hibernate.util.JDBCExceptionReporter  TRAS0014I: The following exception was logged java.sql.SQLException: ORA-01008: not all variables bound


It works find if I use "where parentType='MyEntityType'".

Could anyone show me an example or point me to the doc? I've searched the forums and docs but I might have been blind. :)

Thanks in advance,
Dan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 11:16 am 
Beginner
Beginner

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 20
OK. I did another search in the document, it seems that where clause like this :
Code:
where="parentType=:entityType

can only be used in Query, Session.find() etc. and not for collections in a mapping file.

As workaround, I need to hardcode the :entityType variable in the mapping.

But would it be reasonable to expect that Hibernate will recognize this and automatically bind the class's attribute to the generated query?

regards,
Dan


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.