[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2443) Need a way to query only for specific class types or turning off check for subclasses
Jason (JIRA)
noreply at atlassian.com
Fri Feb 23 14:45:31 EST 2007
Need a way to query only for specific class types or turning off check for subclasses
-------------------------------------------------------------------------------------
Key: HHH-2443
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2443
Project: Hibernate3
Type: Task
Versions: 3.1.3
Environment: 3.1.3, oracle 10.2.0.2
Reporter: Jason
I have two generic tables with the possibility of a lot of data in each.
One called instance and one called association. Each has there own properties table instance_property and association_property. They each have there own mapping files which I will list below.
In the code, Association extends Instance.
So the problem I am having is everytime I query for Instance i.e. HQL - from instance i where type=:type.
This will create two queries "select i.* from instance i where i.type=:type" and "select i.* from association i where i.type=:type".
Since Instance, Association, InstanceProperty, and AssociationProperty have there own mapping files and they both have there own tables (therefore no discriminators), how can I only have it query on Instance?
And querying on Association is fine since it does not have subclasses and it only executes one query.
Am I missing something, or is this just not possible at this time?
In summary, I am requesting a way for HQL to only query on the instance class I specify without checking the subclasses.
<!-- Instance -->
<class name="Instance" table="instance">
<cache usage="read-write" />
<id name="id" column="id" type="java.lang.Long">
<generator class="assigned" />
</id>
<version name="version" column="version" type="long" />
<map name="propertiez" table="instance_to_property">
<cache usage="read-write" />
<key column="instance_id" />
<index column="name" type="string" />
<many-to-many class="InstanceProperty"
column="instance_property_id" fetch="join" />
</map>
</class>
<class name="InstanceProperty"
table="instance_property">
<cache usage="read-write" />
<id name="id" column="id" type="long">
<generator class="native" />
</id>
<version name="version" column="version" type="long" />
<property name="name" column="name" type="string"
not-null="true" />
<property name="key" column="is_key" type="boolean"
not-null="true" />
<property name="value" column name="value" type="string"/>
</property>
</class>
<!-- Association -->
<class name="Association" table="association">
<cache usage="read-write" />
<id name="id" column="id" type="java.lang.Long">
<generator class="assigned" />
</id>
<version name="version" column="version" type="long" />
<map name="propertiez" table="association_to_property">
<cache usage="read-write" />
<key column="association_id" />
<index column="name" type="string" />
<many-to-many class="AssociationProperty"
column="association_property_id" fetch="join" />
</map>
<property name="referenceId1" column="referenceId1"
type="java.lang.Long" />
<property name="referenceId2" column="referenceId2"
type="java.lang.Long" />
</class>
<class name="AssociationProperty"
table="association_property">
<cache usage="read-write" />
<id name="id" column="id" type="long">
<generator class="native" />
</id>
<version name="version" column="version" type="long" />
<property name="name" column="name" type="string"
not-null="true" />
<property name="key" column="is_key" type="boolean"
not-null="true" />
<property name="value" column name="value" type="string"/>
</property>
</class>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list