[Hibernate-JIRA] Created: (HHH-4827) Incorrect SQL is generated when querying indexed scalar maps using 'or'
by Gergely K (JIRA)
Incorrect SQL is generated when querying indexed scalar maps using 'or'
-----------------------------------------------------------------------
Key: HHH-4827
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4827
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.2
Reporter: Gergely K
Priority: Critical
Attachments: hql-index-bug.zip
Querying indexed maps works fine with:
from Entity e where e.map['aaa'] = 'foo'
This generates the following (correct) SQL:
select entity0_.ID as ID0_ from ENTITY entity0_, map map1_
where entity0_.ID=map1_.ID and map1_.NAME = 'aaa' and map1_.VALUE='foo'
However, an unexpected SQL is generated, when using an OR expression:
from Entity e where ( map['aaa'] = 'foo' or map['bbb'] = 'bar')
Generated SQL is:
select entity0_.ID as ID0_ from ENTITY entity0_, map map1_, map map2_ where entity0_.ID=map1_.ID and map1_.NAME = 'aaa' and entity0_.ID=map2_.ID and map2_.NAME = 'bbb' and (map1_.VALUE='foo' or map2_.VALUE='bar')
My problem is: the query returns no results when the map does not contain the key 'bbb', even if it does contain a key for 'aaa' (so the semantics of the HQL 'OR' are not translated correctly). Simply because the OR statement does not contain the "map2_.NAME = 'bbb'" part.
(Moreover, the same map is joined twice, but this is only a performance issue.)
Any workaround or suggestion is greatly appreciated.
I've attached a simple test case for viewing the generated SQL (best viewed with eclipse + m2eclipse).
--
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
16 years, 2 months
[Hibernate-JIRA] Created: (HHH-4455) Changes are not properly rollbacked after a bulk operation involving classes that use joined-subclass mapping
by dilbert (JIRA)
Changes are not properly rollbacked after a bulk operation involving classes that use joined-subclass mapping
-------------------------------------------------------------------------------------------------------------
Key: HHH-4455
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4455
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.0.SP1, 3.2.5
Environment: Hibernate 3.2.5.ga and 3.3.0.SP1
MySql database version 5.1.36
Driver : mysql-connector-java-5.1.6
Reporter: dilbert
Attachments: TransactionTest.zip
I have a Location class on which two other classes "depend" (Contact and LocationTransaction).
When I want to delete a Location Object I use bulk update operations. First I delete the LocationTransactions
connected to the Location object and then I delete the contact objects connected to the location object. Finally
I delete the Location object itself. At the end I simulate that something went wrong and trigger a Rollback.
After the rollback I would expect that none of the objects that I tried to delete was actually deleted. However,
all the LocationTransaction objects are missing from the database after the rollback. Since the other objects
are rollbacked properly I figure that the problem is connected to the fact that LocationTransactions is inherited
from Transaction and uses joined-subclass mapping which is included in the test project in the attachment.
private static void doTest() {
final Session s = sf.openSession();
final Transaction tx = s.beginTransaction();
try {
Location l = (Location) s.createQuery("from Location l where l.name = 'l1'").uniqueResult();
final Query deleteTransactionQuery = s.createQuery(
"delete from LocationTransaction lt " +
"where lt.location = (:location)");
deleteTransactionQuery.setParameter("location", l);
deleteTransactionQuery.executeUpdate();
final Query deleteContactQuery = s.createQuery(
"delete from Contact c " +
"where c.location = (:location)");
deleteContactQuery.setParameter("location", l);
deleteContactQuery.executeUpdate();
final Query deleteQuery = s.createQuery(
"delete from Location l where l = (:location)");
deleteQuery.setParameter("location", l);
deleteQuery.executeUpdate();
//s.delete(l);
throw new RuntimeException("test");
//tx.commit();
} catch (Exception e) {
tx.rollback();
System.out.println(e);
} finally {
s.close();
}
}
Please contact me with any further questions.
Thanks for the help.
--
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
16 years, 2 months
[Hibernate-JIRA] Created: (HHH-2094) Hibernate is ignoring native sql aliases and generating "column not found" error
by Leonardo Penczek (JIRA)
Hibernate is ignoring native sql aliases and generating "column not found" error
--------------------------------------------------------------------------------
Key: HHH-2094
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2094
Project: Hibernate3
Type: Bug
Components: query-sql
Versions: 3.2.0.cr4
Environment: 3.2.0.cr4, Adaptive Server Enterprise/12.5.3
Reporter: Leonardo Penczek
Priority: Critical
As simples as that:
1: Query q = em.createNativeQuery("select cd_person as codePerson, cd_person as identif from PERSON");
2: List<Object[]> resultList = (List<Object[]>) q.getResultList();
Hibernate is ignoring my aliases when retrieving information from the ResultSet because it is trying to retrieve by column name, generating the following error:
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:641)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
at <my line 2 in the code above>
...
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2147)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
...
Caused by: java.sql.SQLException: S0022: Invalid column name 'cd_person'.
at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(Unknown Source)
at com.sybase.jdbc3.tds.TdsResultSet.findColumnByLabel(Unknown Source)
at com.sybase.jdbc3.jdbc.SybResultSet.findColumn(Unknown Source)
at com.sybase.jdbc3.jdbc.SybResultSet.getInt(Unknown Source)
at org.jboss.resource.adapter.jdbc.WrappedResultSet.getInt(WrappedResultSet.java:690)
at org.hibernate.type.IntegerType.get(IntegerType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:139)
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.extract(CustomLoader.java:474)
at org.hibernate.loader.custom.CustomLoader$ResultRowProcessor.buildResultRow(CustomLoader.java:420)
at org.hibernate.loader.custom.CustomLoader.getResultColumnOrRow(CustomLoader.java:317)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:594)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
Awesome! The SQL query runs, but the Hibernate try to get the column by the original name, not by the alias, causing the error!
It is not possible to correctly get the value of 2 different columns that have the same name!!!!
Hint: why Hibernate use ResultSet.get* by column name instead of positional ResultSet.get* (1, 2, 3,...)? It will solve this problem.
--
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
16 years, 2 months
[Hibernate-JIRA] Created: (HHH-4821) Using two @ManyToOne in a @Entity generates an error
by Benoit Coppens (JIRA)
Using two @ManyToOne in a @Entity generates an error
----------------------------------------------------
Key: HHH-4821
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4821
Project: Hibernate Core
Issue Type: Bug
Components: annotations
Affects Versions: 3.3.0.SP1
Environment: hibernate-core-3.3.2.GA, hibernate-annotations-3.4.0.GA, hibernate-c3p0-3.3.2.GA, hsqldb-1.8.0.10.jar
Reporter: Benoit Coppens
Attachments: manyToOne.zip
Mapping a child entity collection from two different parent entities results in duplicate backref property exception when configuring the session factory. Error log is:
org.hibernate.MappingException: Duplicate property mapping of _mappingsBackref found in domain.AttributeMapping
at org.hibernate.mapping.PersistentClass.checkPropertyDuplication(PersistentClass.java:477)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:467)
at org.hibernate.mapping.RootClass.validate(RootClass.java:215)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1149)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1334)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at hibernate.Insert.main(Insert.java:22)
Seems to be the same kinf of issue as HHH-2598
Attached project reproduces the issue
--
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
16 years, 2 months