[Hibernate-JIRA] Created: (HHH-5133) Refresh causes assertion failure on OneToMany (cascaded) property with new members
by Ramon Casha (JIRA)
Refresh causes assertion failure on OneToMany (cascaded) property with new members
----------------------------------------------------------------------------------
Key: HHH-5133
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5133
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.1
Environment: Oracle 10g
Reporter: Ramon Casha
An entity with a OneToMany property (cascade=all) is retrieved from the DB, then a NEW instance is added to the OneToMany property. If you call refresh on the parent it will give an assertion failure because Hibernate tries to refresh the added object although it is not persistent.
eg:
class Child { }
class Parent {
@OneToMany(cascade=ALL) List<Child> children;
}
Parent p = em.find(Parent.class, 1);
p.children.add(new Child());
em.refresh(p);
This causes:
org.hibernate.AssertionFailure: null identifier
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:61)
at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:102)
at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:1117)
at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:1100)
at org.hibernate.engine.CascadingAction$3.cascade(CascadingAction.java:203)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:392)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:335)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:425)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:362)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:338)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:204)
at org.hibernate.engine.Cascade.cascade(Cascade.java:161)
at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:127)
at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:62)
at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:1108)
at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:1088)
at org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:734)
at org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:709)
--
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
14 years, 6 months
[Hibernate-JIRA] Created: (HHH-5128) [regression] Columns named "to_date" no longer work
by Ramon Casha (JIRA)
[regression] Columns named "to_date" no longer work
---------------------------------------------------
Key: HHH-5128
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5128
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.1
Environment: Database = Oracle 10g
Reporter: Ramon Casha
Using Hibernate 3.2, I had columns named from_date and to_date - these worked without problems.
Since upgrading to Hibernate 3.5, the column to_date no longer works. When generating SQL queries, this column is not prefixed by the table alias name. For example, Hibernate generates the following SQL:
select
amounts0_.from_date as from14_44_1_,
to_date as to18_44_1_
--etc--
from reg_alloc_amount amounts0_
left outer join reg_alloc_amount allocamoun1_ on amounts0_.rec_link_id=allocamoun1_.alloc_amount_id
This gives java.sql.SQLException: ORA-00918: column ambiguously defined
I suspect that Hibernate treats to_date as an Oracle function instead of a column.
--
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
14 years, 6 months
[Hibernate-JIRA] Created: (HHH-4921) 3.5 (JPA 2) doesn't allow order by alias
by Tomasz Bech (JIRA)
3.5 (JPA 2) doesn't allow order by alias
----------------------------------------
Key: HHH-4921
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4921
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-CR-1
Reporter: Tomasz Bech
Attachments: JPAQLComplianceTest.java
I've created following test case in JPAQLComplianceTest.java:
public void testOrderByAlias() {
Session s = openSession();
s.createQuery( "select c.name as myname FROM Item c ORDER BY myname" ).list();
s.close();
}
and it fails:
Caused by: java.sql.SQLException: Column not found: MYNAME in statement [select item0_.NAME as col_0_0_ from EJB3_ITEM item0_ order by myname]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1598)
at org.hibernate.loader.Loader.doQuery(Loader.java:718)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:271)
at org.hibernate.loader.Loader.doList(Loader.java:2273)
... 30 more
Spec says in '4.9 ORDER BY Clause' that 'order by alias' is supported by JPA 2.
--
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
14 years, 6 months
[Hibernate-JIRA] Created: (HHH-5051) JPA 2 Criteria Query with Object as Parameter not Working
by Guido Müller (JIRA)
JPA 2 Criteria Query with Object as Parameter not Working
---------------------------------------------------------
Key: HHH-5051
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5051
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0-CR-2
Reporter: Guido Müller
Priority: Blocker
The problem is with this scenario:
2 Entity classes A and B
We have a 1:N relation between A (N) and B (1)
This test fails:
I get one instance of B with the entity manager find method.
I query the database with JPA 2 query to get a list of all instances of A that have the many-to-one property equals the instance got from the 1st step.
Code:
EntityManager em = ...
B b = em.find(B.class, 1L);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<A> q = cb.createQuery(A.class);
Root<A> p = q.from(A.class);
q.select(p).where(cb.equal(p.get(A_.b), b));
List<A> l = em.createQuery(q).getResultList();
em.close();
This does not work but it should. It works properly with EclipseLink. In Hibernate I get this to work when I provide b.getId() as Parameter. But this is not correct!
--
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
14 years, 6 months