[Hibernate-JIRA] Created: (HHH-2688) HQL: Incorrect join when ordering by property of nullable many-to-one
by Scott Van Wart (JIRA)
HQL: Incorrect join when ordering by property of nullable many-to-one
---------------------------------------------------------------------
Key: HHH-2688
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2688
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.4.sp1
Environment: Oracle 10gR2
Reporter: Scott Van Wart
Attachments: pojos_and_mappings.zip
I have two tables: Parent and Child. Children may not have a parent. I want to select all children, ordering by parent name:
TABLE parent_table ( parent_id NUMBER PRIMARY KEY, parent_name VARCHAR2(30) NOT NULL );
TABLE child_table ( child_id NUMBER PRIMARY KEY, parent_id REFERENCES parent ON DELETE SET NULL );
So I create the two POJOs and mapping documents (attached). After openSession():
List children = session.createQuery( "from Child c order by c.parent.name" ).list();
I only get back the children with parents, because here's the generated SQL, with an INNER join:
select child0_.child_id as child1_17_, child0_.parent_id as parent2_17_
from child_table child0_, parent_table parent1_
where child0_.parent_id=parent1_.parent_id
order by parent1_.parent_name;
Because parent_id in the child table is nullable, I would expect the generated SQL to be:
select child_id, parent_id
from child_table c LEFT JOIN parent_table p ON c.parent_id = p.parent_id
order by p.parent_name;
I guess a workaround might be to specify the join type explicitly in the HQL, but this default behavior kind of surprised me. Thanks.
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2751) MappedSuperclass + M:N relation + PostUpdateListener = AssertionFailure: collection [xyz] was not processed by flush()
by S.Schnabl (JIRA)
MappedSuperclass + M:N relation + PostUpdateListener = AssertionFailure: collection [xyz] was not processed by flush()
----------------------------------------------------------------------------------------------------------------------
Key: HHH-2751
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2751
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4.sp1, 3.2.4, 3.2.3, 3.2.2, 3.2.1
Environment: Windows-XP, Jboss 4.2 GA, Hibernate 3.2.1GA, EJB3
Reporter: S.Schnabl
Attachments: Hibernate-TestCase.rar
For more details see the attached testcase. I'm sorry, but in the short of time i only got a testcase for jboss-server 4.2. Please deploy the server.ear from /release-directory and then call the /src/client/TestCaseClient.java.
Explanation:
I have two entities A.class and B.class defined, both inheriting from an common (empty) abstract MappedSuperclass. A and B having a m:n relation between each other. Furthermore there is an PostUpdateListener, which iterates through all properties of updated entities.
Testcase:
Both entities are linked with each (m:n), now i do an update of a simple property of entity A --> MyPostUpdateListener will be called, which iterates through each property of the updated entity(ies). In case of this property was a collection (= property of the m:n relation), the listener furthermore iterates through this collection and get the id of each object in the collection. Doing so will raise following exception :
Caused by: org.hibernate.AssertionFailure: collection [com.qualitype.testcase.server.ejb.entity.EntityB.entitiesOfA] was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:205)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:333)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
... 29 more
Summarized these error will only occur, in case we are inherating from a mappedSuperClass, having a m:n relation and having the listener touching the collection-elements. But these scenario isn'n very uncommon. We are using hibernate-event listener system for auditing-purposes, so you should understand that touching ever (element in the) collectin is necessary for audit-purposes.
Seems for me like a bug. Need this fixed asap ...
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2653) DetachedCriteria does not create assocation criteria with alias
by Jörg Heinicke (JIRA)
DetachedCriteria does not create assocation criteria with alias
---------------------------------------------------------------
Key: HHH-2653
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2653
Project: Hibernate3
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.2.4.sp1
Reporter: Jörg Heinicke
It's known that ordering on association properties in the criteria API only works with aliases (http://forum.hibernate.org/viewtopic.php?t=972241 and countless other threads, HHH-2629). Unfortunately, you can't even use the aliases with DetachedCriteria since it has a bug:
public DetachedCriteria createCriteria(String associationPath, String alias) throws HibernateException {
return new DetachedCriteria( impl, criteria.createCriteria(associationPath) );
}
public DetachedCriteria createCriteria(String associationPath) throws HibernateException {
return new DetachedCriteria( impl, criteria.createCriteria(associationPath) );
}
As you can see both implementations are equal, the first one ignores the alias parameter. It has to be
public DetachedCriteria createCriteria(String associationPath, String alias) throws HibernateException {
return new DetachedCriteria( impl, criteria.createCriteria(associationPath, alias) );
}
--
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, 3 months