-->
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: Is it possible to bypassing "compId" identifier fi
PostPosted: Thu May 13, 2004 11:53 pm 
Newbie

Joined: Mon Jan 12, 2004 2:24 am
Posts: 16
Hi all..

For a composite PK, Hibernate will create an identifer field called "compId".
Is it *possible* to access the field inside that "compId".

This HQL will *work* because I go through "compId" first:

select registrationItem "
from RegItem registrationItem
where registrationItem.compId.actvGrpId_ = '10002' "

This HQL, which try to "bypassing" compId, does *not* work, Hibernate gives error message: could not resolve property: actvGrpId_ of: com.myCompany.RegItem
for this HQL:

select registrationItem
from RegItem registrationItem
where registrationItem.actvGrpId_ = '10002'

So.. is my attempt to bypassing "compId" is possible by any workaround?
I need to do that because to avoid creating mapping between
fields where those fields are generated dynamically.

For example in my code:

/** @author Hibernate CodeGenerator */
public class RegItem implements Serializable {

/** identifier field */
private com.mycompany.PKRegItem compId;


---------------

Here's the content of PKRegItem:

/** @author Hibernate CodeGenerator */
public class PKRegItem implements Serializable {

/** identifier field */
private long actvGrpId_;

/** identifier field */
private int actvId_;

---

Here's the content of my hbm.xml
<class name="com.mycompany.RegItem" table="REG_ITEM">
<composite-id name="compId" class="com.mycompany.PKRegItem">
<key-property name="actvGrpId_" type="long">
<column name="actv_grp_id" sql-type="number(10)" not-null="true"/>
</key-property>
<key-property name="actvId_" type="integer">
<column name="actv_id" sql-type="number(4)" not-null="true"/>
</key-property>
</composite-id>


I'm using Hibernate 2.1.2, Oracle 8i.

Thanks a lot for any advice.

regards,
Dion

_________________
~Dion


Top
 Profile  
 
 Post subject: Re: Is it possible to bypassing "compId" identifie
PostPosted: Fri May 14, 2004 6:21 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
d10n2000 wrote:
For a composite PK, Hibernate will create an identifer field called "compId".
Is it *possible* to access the field inside that "compId".

This HQL will *work* because I go through "compId" first:

select registrationItem "
from RegItem registrationItem
where registrationItem.compId.actvGrpId_ = '10002' "

So.. is my attempt to bypassing "compId" is possible by any workaround?


You can acces all fields inside your composite-id using either composite-id name, in your case it is "compId" or standard "id" name, try this:
Code:
from RegItem registrationItem
where registrationItem.id.actvGrpId_ = '10002'


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.