Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: \
3.1.3
Mapping documents:
<hibernate-mapping auto-import="false" default-access="com.pontis.platform.tgp.persistence.hibernate.PropertyBridge" default-cascade="none" default-lazy="true">
<class name="com.pontis.app.general.AppReference" table="APPREFERENCE" lazy="false" select-before-update="false" dynamic-update="false" dynamic-insert="false" discriminator-value="com.pontis.app.general.AppReference" >
<cache usage="read-write" />
<id type="java.lang.String" column="id" name="id">
<generator class="assigned" />
</id>
<discriminator type="string" force="false" insert="true"
column="my_discriminator" />
<version name="version" column="version"
type="java.lang.Integer"/>
.
.
.
</class>
<hibernate-mapping auto-import="false" default-cascade="none" default-lazy="true">
<subclass name="com.pontis.app.subscriber.SubscriberValue" extends="com.pontis.app.general.AppReference" lazy="false" select-before-update="false" discriminator-value="com.pontis.app.subscriber.SubscriberValue" />
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
getHibernateTemplate().find("From com.pontis.app.subscriber.SubscriberValue
where refcode="123");
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Hibernate: select subscriber0_.id as id25_, subscriber0_.version as version25_, subscriber0_.lifeCycleState as lifeCycl4_25_, subscriber0_.creator as creator25_, subscriber0_.lastModifiedBy as lastModi6_25_, subscriber0_.availableFlag as availabl7_25_, subscriber0_.creationDate as creation8_25_, subscriber0_.lastModifiedDate as lastModi9_25_, subscriber0_.refCode as refCode25_, subscriber0_.refCodeDisplayString as refCode11_25_ from APPREFERENCE subscriber0_ where 1=2 and subscriber0_.refCode=?
Debug level Hibernate log excerpt:
I have a class, and a subclass. they are mapped onto the same table.
I am able to insert values of the sublcass through hibernate fine, but trying to perform a queryt on the subclass generates the above SQL that has a condition "where 1=2" - something that indicates that hiberate thinks it shouldn't return the results.
One more thing - the class (not subclass) extends a different class, which is not mapped at all.
so we have
SomeAbstractClass (not mapped)
|
AppReference(mapped as <class>)
|
SubscriberValue(mapped as <subclass>)
if I try to map the same classes using a table per subclass approach - all is well.
Any idea?
Assaf.