[Hibernate-JIRA] Created: (HHH-2443) Need a way to query only for specific class types or turning off check for subclasses
by Jason (JIRA)
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
17 years, 10 months
[Hibernate-JIRA] Created: (HBX-904) Refreshing the session factory doesn't refresh everything
by Joseph Marques (JIRA)
Refreshing the session factory doesn't refresh everything
---------------------------------------------------------
Key: HBX-904
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-904
Project: Hibernate Tools
Type: Bug
Versions: 3.2beta8
Reporter: Joseph Marques
i was writting a query that used composite objects, such as:
select new Thing(elt1, elt2) from .....
I changed the constructor arguments for Thing.java and saved them. Then I right-clicked on the session factory and pressed 'refresh'. I updated my query to pass the new argument, but it reported:
"org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [some.long.package.name.Thing] [<the query I was trying to execute>]
Then I tried right-clicking the configuration itself and selecting 'refresh' at this higher level...but I still got the same error.
Then I tried closing and re-opening the session factory (again, rlght-click context menu on the configuration). This time it worked.
So I guess I'm just wondering why refresh doesn't refresh the class definitions too.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
17 years, 10 months
Why sometimes the Transaction is required for Query, sometimes not ?
by Miroslav Nachev
Why sometimes the transaction is required for query, sometimes the
transaction is not required?
Where and what is the logic for that?
In my opinion the transaction is not required for any query, but today I
use Oracle 10g where was impossible to make Query without transaction:
public static List<Order> getOrders()
{
Session session = getSessionFactory().getCurrentSession();
Transaction transaction = session.beginTransaction();
try
{
List<Order> orders = (List<Order>)session.createQuery("from Order").list();
transaction.commit();
transaction.begin();
return orders;
}
catch(Throwable ex)
{
transaction.rollback();
session.close();
ex.printStackTrace();
throw new RuntimeException(ex);
}
}
I am looking in other projects which use MySQL and Derby where the
transaction is not required for query.
Now I am trying to make the same situation for Derby but the query is
processing fine without transaction.
Can somebody tell me where is the true and is it possible to configure
Hibernate when use Oracle to make Query without using transactions?
Thank you in advance.
Regards,
Miro
17 years, 10 months