Hibernate version:
3.2.2
Mapping documents:
Code:
<hibernate-mapping package="de.portal.permission">
<class name="Rights" table="RIGHTS">
<id name="id" unsaved-value="null">
<generator class="native"/>
</id>
<discriminator column="type" type="string" />
<set name="rights" inverse="true" cascade="all-delete-orphan">
<key column="parent"/>
<one-to-many class="Rights"/>
</set>
<many-to-one name="parent" column="parent" cascade="save-update" class="Rights"/>
<property name="name" type="string" unique="true" />
<subclass name="User" discriminator-value="user">
<property name="password" type="string" />
</subclass>
<subclass name="Group" discriminator-value="group">
</subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
PersistenceManager.beginTransaction();
Query query = session.createQuery("from Rights as r where parent.name=:name and r.class=Group").setParameter("name",groupName);
List<Rights> result = query.list();
PersistenceManager.commitTransaction();
Full stack trace of any exception that occurs:
javax.servlet.ServletException: cant't fetch members: unexpected token: Group near line 1, column 69 [from de.portal.permission.Rights as r where parent=null and r.class=Group]
Name and version of the database you are using:
MySQL 5.0.26
The generated SQL (show_sql=true):
none
So I want to fetch only the groups (=> type="group"). If I change r.class=Group to r.class=User all works well, but with "Group" as filter I get the above Exception.
Any idea why User works and Group doesn't?
Greets,
Ace