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:
|