Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.5
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE
hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Entity" table="ENTITY"
batch-size="50">
<cache usage="read-write" />
<id name="id" column="ID" unsaved-value="-1">
<generator class="increment"></generator>
</id>
<set name="stringAttributes" table="ATTRIBUTERELATIONSHIP"
lazy="false" cascade="all-delete-orphan"
where="DISCRIMINATOR = 1" fetch="subselect">
<key column="ENTITYID" not-null="true"></key>
<one-to-many class="StringAttribute" />
</set>
<set name="integerAttributes" table="ATTRIBUTERELATIONSHIP"
lazy="false" cascade="all-delete-orphan"
where="DISCRIMINATOR = 2" fetch="subselect">
<key column="ENTITYID" not-null="true"></key>
<one-to-many class="IntegerAttribute" />
</set>
<set name="dateAttributes" table="ATTRIBUTERELATIONSHIP"
lazy="false" cascade="all-delete-orphan"
where="DISCRIMINATOR = 3" fetch="subselect">
<key column="ENTITYID" not-null="true"></key>
<one-to-many class="DateAttribute" />
</set>
</class>
</hibernate-mapping>
Code:
<!DOCTYPE
hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Attribute"
table="ATTRIBUTERELATIONSHIP" discriminator-value="-1"
batch-size="50">
<cache usage="read-write" />
<id name="id" column="ID" unsaved-value="-1">
<generator class="increment"></generator>
</id>
<discriminator column="DISCRIMINATOR" not-null="true"
force="true" />
<many-to-one name="attributeClass"
class="AttributeClass"
column="ATTRIBUTECLASSID" cascade="save-update" lazy="false">
</many-to-one>
<property name="insertionDate" column="INSERTIONDATE">
</property>
<property name="startDate" column="STARTDATE"></property>
<property name="stopDate" column="STOPDATE"></property>
<subclass name="DateAttribute"
discriminator-value="3" batch-size="50">
<many-to-one name="dateValue"
class="DateValue" column="VALUEID"
not-null="true" cascade="save-update" lazy="false">
</many-to-one>
</subclass>
<subclass name="StringAttribute"
discriminator-value="1" batch-size="50">
<many-to-one name="stringValue"
class="StringValue"
column="VALUEID" not-null="true" cascade="save-update"
lazy="false"></many-to-one>
</subclass>
<subclass name="IntegerAttribute"
discriminator-value="2" batch-size="50">
<many-to-one name="integerValue"
class="IntegerValue"
column="VALUEID" not-null="true" cascade="save-update"
lazy="false"></many-to-one>
</subclass>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE
hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="StringValue"
table="STRINGATTRIBUTE" batch-size="50">
<cache usage="read-write" />
<id name="id" column="ID" unsaved-value="-1">
<generator class="increment"></generator>
</id>
<property name="value" column="VALUE"></property>
</class>
</hibernate-mapping>
integer and date are similarly mapped to their own "value" tablesCode between sessionFactory.openSession() and session.close():Code:
Criteria criteria = session
.createCriteria(Entity.class)
.setFetchMode("entityClasses", FetchMode.SELECT)
.createCriteria("stringAttributes", "stringAttribute")
.createAlias("stringAttribute.stringValue", "stringValue")
.createAlias("stringAttribute.attributeClass", "attributeClass")
.add(Restrictions.and(
Expression.eq("attributeClass.name", name),
Expression.eq("stringValue.value", value)));
Set results = new HashSet(criteria.list());
Full stack trace of any exception that occurs:
No Exception
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
Hibernate: select this_.ID as ID3_, stringattr1_.ID as ID0_, stringattr1_.ATTRIBUTECLASSID as ATTRIBUT3_2_0_, stringattr1_.INSERTIONDATE as INSERTIO4_2_0_, stringattr1_.STARTDATE as STARTDATE2_0_, stringattr1_.STOPDATE as STOPDATE2_0_, stringattr1_.VALUEID as VALUEID2_0_, attributec3_.ID as ID1_, attributec3_.NAME as NAME7_1_, stringvalu2_.ID as ID2_, stringvalu2_.VALUE as VALUE3_2_ from ENTITY this_ inner join ATTRIBUTERELATIONSHIP stringattr1_ on this_.ID=stringattr1_.ENTITYID and stringattr1_.DISCRIMINATOR = 1 and stringattr1_.DISCRIMINATOR='1' inner join ENTITYCLASS attributec3_ on stringattr1_.ATTRIBUTECLASSID=attributec3_.ID inner join STRINGATTRIBUTE stringvalu2_ on stringattr1_.VALUEID=stringvalu2_.ID where (attributec3_.NAME=? and stringvalu2_.VALUE=?)
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select dateattrib0_.ENTITYID as ENTITYID1_, dateattrib0_.ID as ID1_, dateattrib0_.ID as ID0_, dateattrib0_.ATTRIBUTECLASSID as ATTRIBUT3_2_0_, dateattrib0_.INSERTIONDATE as INSERTIO4_2_0_, dateattrib0_.STARTDATE as STARTDATE2_0_, dateattrib0_.STOPDATE as STOPDATE2_0_, dateattrib0_.VALUEID as VALUEID2_0_ from ATTRIBUTERELATIONSHIP dateattrib0_ where dateattrib0_.DISCRIMINATOR = 3 and dateattrib0_.DISCRIMINATOR='3' and dateattrib0_.ENTITYID in (select this_.ID from ENTITY this_ inner join ATTRIBUTERELATIONSHIP stringattr1_ on this_.ID=stringattr1_.ENTITYID and stringattr1_.DISCRIMINATOR = 1 and stringattr1_.DISCRIMINATOR='1' inner join ENTITYCLASS attributec3_ on stringattr1_.ATTRIBUTECLASSID=attributec3_.ID inner join STRINGATTRIBUTE stringvalu2_ on stringattr1_.VALUEID=stringvalu2_.ID where (attributec3_.NAME=? and stringvalu2_.VALUE=?))
Hibernate: select integeratt0_.ENTITYID as ENTITYID1_, integeratt0_.ID as ID1_, integeratt0_.ID as ID0_, integeratt0_.ATTRIBUTECLASSID as ATTRIBUT3_2_0_, integeratt0_.INSERTIONDATE as INSERTIO4_2_0_, integeratt0_.STARTDATE as STARTDATE2_0_, integeratt0_.STOPDATE as STOPDATE2_0_, integeratt0_.VALUEID as VALUEID2_0_ from ATTRIBUTERELATIONSHIP integeratt0_ where integeratt0_.DISCRIMINATOR = 2 and integeratt0_.DISCRIMINATOR='2' and integeratt0_.ENTITYID in (select this_.ID from ENTITY this_ inner join ATTRIBUTERELATIONSHIP stringattr1_ on this_.ID=stringattr1_.ENTITYID and stringattr1_.DISCRIMINATOR = 1 and stringattr1_.DISCRIMINATOR='1' inner join ENTITYCLASS attributec3_ on stringattr1_.ATTRIBUTECLASSID=attributec3_.ID inner join STRINGATTRIBUTE stringvalu2_ on stringattr1_.VALUEID=stringvalu2_.ID where (attributec3_.NAME=? and stringvalu2_.VALUE=?))
Hibernate: select stringattr0_.ENTITYID as ENTITYID1_, stringattr0_.ID as ID1_, stringattr0_.ID as ID0_, stringattr0_.ATTRIBUTECLASSID as ATTRIBUT3_2_0_, stringattr0_.INSERTIONDATE as INSERTIO4_2_0_, stringattr0_.STARTDATE as STARTDATE2_0_, stringattr0_.STOPDATE as STOPDATE2_0_, stringattr0_.VALUEID as VALUEID2_0_ from ATTRIBUTERELATIONSHIP stringattr0_ where stringattr0_.DISCRIMINATOR = 1 and stringattr0_.DISCRIMINATOR='1' and stringattr0_.ENTITYID in (select this_.ID from ENTITY this_ inner join ATTRIBUTERELATIONSHIP stringattr1_ on this_.ID=stringattr1_.ENTITYID and stringattr1_.DISCRIMINATOR = 1 and stringattr1_.DISCRIMINATOR='1' inner join ENTITYCLASS attributec3_ on stringattr1_.ATTRIBUTECLASSID=attributec3_.ID inner join STRINGATTRIBUTE stringvalu2_ on stringattr1_.VALUEID=stringvalu2_.ID where (attributec3_.NAME=? and stringvalu2_.VALUE=?))
Hibernate: select attributec0_.ID as ID0_, attributec0_.NAME as NAME7_0_ from ENTITYCLASS attributec0_ where attributec0_.ID in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select stringvalu0_.ID as ID0_, stringvalu0_.VALUE as VALUE3_0_ from STRINGATTRIBUTE stringvalu0_ where stringvalu0_.ID in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select stringvalu0_.ID as ID0_, stringvalu0_.VALUE as VALUE3_0_ from STRINGATTRIBUTE stringvalu0_ where stringvalu0_.ID in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select stringvalu0_.ID as ID0_, stringvalu0_.VALUE as VALUE3_0_ from STRINGATTRIBUTE stringvalu0_ where stringvalu0_.ID in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select attributec0_.ID as ID0_, attributec0_.NAME as NAME7_0_ from ENTITYCLASS attributec0_ where attributec0_.ID in (?, ?)
Hibernate: select stringvalu0_.ID as ID0_, stringvalu0_.VALUE as VALUE3_0_ from STRINGATTRIBUTE stringvalu0_ where stringvalu0_.ID in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select stringvalu0_.ID as ID0_, stringvalu0_.VALUE as VALUE3_0_ from STRINGATTRIBUTE stringvalu0_ where stringvalu0_.ID in (?, ?)
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Hibernate: select entityclas0_.ENTITYID as ENTITYID1_, entityclas0_.CLASSID as CLASSID1_, entityclas1_.ID as ID0_, entityclas1_.NAME as NAME7_0_ from ENTITYCLASSIFICATION entityclas0_ inner join ENTITYCLASS entityclas1_ on entityclas0_.CLASSID=entityclas1_.ID where entityclas0_.ENTITYID=?
Debug level Hibernate log excerpt:
...
I am having a problem when using the Criteria API for querying.
As you can see in the Sql Statements, there is a redundant subselect that occurs for every "attribute type" (in bold above). This is a rather expensive call, and at that point the pk for the result object (Entity.class) is already known (from the first select).
How can i optimize my mapping/criteria query to avoid these unneccessary subselects? Also, how can i make the ENTITYCLASSIFICATION selects rollup into batches (they are specified as join's in the mapping of Entity)?
Thanks for the Help in advance,
Jason