-->
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.  [ 4 posts ] 
Author Message
 Post subject: Inheritance and HQL
PostPosted: Fri May 28, 2004 8:32 am 
Newbie

Joined: Fri Mar 12, 2004 9:33 am
Posts: 17
Can I pass "class" parameter to query?
I have such mapping:
Code:
   <class name="DPUserGroupType" table="DP_USER_GROUP_TYPES" >
       <id name="id" type="string" >
<!--           <column name="ID" sql-type="number" not-null="true"/>-->
           <generator class="com.amfitel.common.hb.StringSequenceGenerator">
              <param name="sequence" >DP_USER_GROUPS_SEQ</param>
          </generator>
       </id>
      <discriminator column="ID"/>
       <property name="name" type="string" />
        <subclass name="DPAuthUserGroupType" discriminator-value="1" />
        <subclass name="DPDispatchUserGroupType" discriminator-value="2" />
   </class>
   <class name="DPUserGroup" table="DP_USER_GROUPS" lazy="true" >
       <id name="id" type="string" unsaved-value="null" >
           <column name="ID" sql-type="number" not-null="true"/>
           <generator class="com.amfitel.common.hb.StringSequenceGenerator">
              <param name="sequence" >DP_USER_GROUPS_SEQ</param>
          </generator>
       </id>
       <property name="name" type="string" />
      <many-to-one name="type" column="TYPE_ID" not-null="true" class="DPUserGroupType" />
      <set name="users" table="DP_USR_GRP_ENTRIES" inverse="true" lazy="true"  >
         <key column="GROUP_ID"/>
         <many-to-many column="USER_ID" class="DPUser" />
      </set>
      <set name="subscriptions" lazy="true"  inverse="true" >
           <key column="GROUP_ID"/>
         <one-to-many class="DPSubscription" />
      </set>
   </class>

I want to execute this query:
Code:
   select userGroup from com.amfitel.dp.bl.DPUser user join user.groups userGroup
       where user.id=:id and userGroup.type.class=:cl

So when I pass cl parameter as string "com.amfitel.dp.bl.DPAuthUserGroupType", I get exception - java.sql.SQLException: ORA-01722

So is this not supported? And how can I avoid this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 8:33 am 
Newbie

Joined: Fri Mar 12, 2004 9:33 am
Posts: 17
ORA-01722: invalid number


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 31, 2004 1:40 am 
Newbie

Joined: Fri Mar 12, 2004 9:33 am
Posts: 17
Cannot anybody answer??


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 31, 2004 7:47 pm 
Beginner
Beginner

Joined: Mon Sep 29, 2003 10:32 pm
Posts: 35
Location: Toronto, Ontario
Why not just map UserGroup.type as a simple property instead of an object reference. Then you can just use
Code:
userGroup.type.class = 1.


But if you want to keep the object reference, map the column again as a simple property:
Code:
<property name="typeValue" column="TYPE_ID" insert="false" update="false"/>
[/code]


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