-->
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: discriminator-value - using wildcards?
PostPosted: Sat Sep 25, 2004 5:06 pm 
Newbie

Joined: Thu Aug 26, 2004 12:24 pm
Posts: 5
Is it possible to use wild cards in the discriminator-value?
I have a situation where I would like to use a subclass but my discriminator is only valid for the subclass.
That is I can't specify a value for the super class (Group). I want to say that all instances that have column NAME="DEFAULT" should be of class DefaultGroup, otherwise it is base class Group. Is something like that supported?

With the current mapping I obviously get no results for the query.
Thanks
Dmitry
Hibernate version:
2
Mapping documents:
<class name="Group" table="GROUP">
<id name="groupId" column="GROUP_ID" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">GROUP_SEQ</param>
</generator>
</id>
<discriminator column="NAME" type="java.lang.String" force="true"/>
<version name="versionId" column="VERSION_ID" type="java.lang.Long"/>
<property name="customerid" column="CUSTOMERID" type="java.lang.Long" not-null="true" />
<property name="name" column="NAME" type="java.lang.String" not-null="true" />
<property name="description" column="DESCRIPTION" type="java.lang.String" not-null="true" />

<idbag name="levels"
table="APP_GROUP"
cascade="save-update">
<collection-id type="java.lang.Long" column="SEQ">
<generator class="sequence">
<param name="sequence">APP_GROUP_SEQ</param>
</generator>
</collection-id>
<key column="GROUP_ID" />
<many-to-many class="AppLevel" column="APP_LEVEL_ID" />
</idbag>
<subclass name="DefaultGroup"
discriminator-value="DEFAULT">
</subclass>
</class>
Code between sessionFactory.openSession() and session.close():
Criteria c = s.createCriteria(Group.class);
c.add(Expression.eq("customerid", owner));
c.addOrder(Order.asc("groupId"));
result = c.list();
Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
select this.GROUP_ID as GROUP1_0_, this.NAME as NAME0_, this.VERSION_ID as VERSION_ID0_, this.CUSTOMERID as CUSTOMERID0_, this.DESCRIPTION as DESCRIPT5_0_ from GROUP this where this.CUSTOMERID= ? and this.NAME in ('DEFAULT') order by this.GROUP_ID asc
Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 25, 2004 7:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You need to use a formula discriminator in Hibernate3.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 26, 2004 12:57 pm 
Newbie

Joined: Thu Aug 26, 2004 12:24 pm
Posts: 5
Thanks!


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.