[Hibernate-JIRA] Created: (HHH-5992) A query fails to return correct results silently
by Tom Ross (JIRA)
A query fails to return correct results silently
------------------------------------------------
Key: HHH-5992
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5992
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: JBoss EAP 5.1
Reporter: Tom Ross
The following query fails silently to return a correct result select v1.username, v2.username from user_ety v1, user_ety v2 where v1.username = '1' and v2.username = '2'. It returns one row with "1,1" instead of one row with "1,2".
The query works with pre JPA CMP EJBs (ver 2.1) but fails when moved to JPA based persistence.
This failure is very dangerous since it is silent and without manually checking data it is impossible to determine if a correct set is returned.
The workaround is to use aliases and modify the query so it looks like that:
select v1.username as username1, v2.username as username2 from user_ety v1, user_ety v2 where v1.username = '1' and v2.username = '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
13 years, 1 month
[Hibernate-JIRA] Created: (HHH-5454) With hibernate.order_inserts=true Hibernate executes SQL inserts in wrong order
by Oleg Tsernetsov (JIRA)
With hibernate.order_inserts=true Hibernate executes SQL inserts in wrong order
-------------------------------------------------------------------------------
Key: HHH-5454
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5454
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0.Beta2, 3.3.2, 3.3.1, 3.3.0.SP1
Environment: Initially occurred with hibernate-core 3.3.1, Oracle 11g.
Reproduced with hibernate-core 3.3.0 SP1 (and later) and HSQLDB 2.0.0
Reporter: Oleg Tsernetsov
Attachments: jpatest.zip
*General:*
With _hibernate.order_inserts_ configuration property set to _true_ Hibernate executes SQL inserts in wrong order, so that dependent entities are attempted to be inserted before parent entities. This is a production case, so we had to switch off hibernate insert ordering to workaround the problem.
*Test case:*
Test case for reproduce is attached (jpatest.zip). It uses hibernate-entitymanager 3.4.0.GA (hibernate-core 3.3.0 SP1), hsqldb 2.0.0. The problem is also reproducible in later versions of hibernate-core (3.3.1, 3.3.2, 3.6.0.Beta2).
Test case is a typical maven2 project.
In order to run the test case:
- unzip the archive to any folder
- cd jpatest
- mvn test
If change hibernate.order_inserts to _false_ in /jpatest/src/main/resources/META-INF/persistence.xml, then the test passes.
Mappings are located under \jpatest\src\main\resources\META-INF\mappings.hbm.xml
*Data model:*
[Person] 1 -- * [Phone]
[Person] 1 -- * [Relation] * -- 1 [Person]
*Scenario:*
1) Insert plain person P1.
2) Update person P1,
-- add new phone PH1 to person P1
-- add new relation R1 to person P1. Relation R1 refers to a new person P2 having new phone PH2 Update of person P1 generates insert for phone PH1 and cascade inserts for P2, PH2 and R1.
Once inserts are ordered, insert clauses for phones PH1 and PH2 come first. As insert for PH2 is executed before the insert of its parent entity P2, the whole operation fails due to parent key not found.
With Oracle DB it results in java.sql.BatchUpdateException: ORA-02291: integrity constraint (PHONE_PERSON_FK) violated - parent key not found
With HSQLDB - java.sql.BatchUpdateException: integrity constraint violation: foreign key no parent; PHONE_PERSON_FK table: PHONE
*Problematic code*
org.hibernate.engine.ActionQueue.InsertActionSorter.findBatchNumber(), uses only _property_ types to determine batch number, but in given case cascade goes through composite primary key of Phone, so the code should also deep-traverse action.getPersister().getClassMetadata().getIdentifierType().
*Another problem*
When I tried to change phone collection mapping in Person entity from _<map>_ to _<set>_ (with hope to workaround the issue), then I got another error:
java.lang.NullPointerException
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:136)
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:144)
at org.hibernate.type.EntityType.getHashCode(EntityType.java:312)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:212)
at org.hibernate.engine.EntityKey.generateHashCode(EntityKey.java:126)
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:70)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:184)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:144)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:154)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:110)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:636)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:628)
at org.hibernate.engine.EJB3CascadingAction$1.cascade(EJB3CascadingAction.java:28)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:291)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:239)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:192)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:319)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:265)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:242)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:192)
at org.hibernate.engine.Cascade.cascade(Cascade.java:153)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:479)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsPersistent(DefaultPersistEventListener.java:134)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:107)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:645)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:619)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:623)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220)
at com.test.AppTest.testJPA(AppTest.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Please pay attention to it as well.
--
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
13 years, 1 month
[Hibernate-JIRA] Created: (HHH-3220) Patch to prevent "org.hibernate.AssertionFailure: possible non-threadsafe access to the session" error caused by stateless sessions
by Dan Bisalputra (JIRA)
Patch to prevent "org.hibernate.AssertionFailure: possible non-threadsafe access to the session" error caused by stateless sessions
-----------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3220
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3220
Project: Hibernate3
Issue Type: Patch
Components: core
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6, Apache Derby on Mac OSX & PC
Reporter: Dan Bisalputra
Priority: Minor
When performing a query in a stateless session, the query loads objects in a two-phase process in which a temporary persistence context is populated with empty objects in the first phase, then the objects' member data are read from the database in the second phase. If one of the objects contains an association or a collection, it performs a recursive call to the session's get() method. The get() method clears the temporary persistence context, so if the parent object contains any other associations to be read in the second phase, Hibernate throws an assertion because they are not found in the persistence context.
This patch solves the problem by only clearing the persistence context when the recursion ends. It passes all the unit tests for our application, but I have not tested it with any of the Hibernate unit tests.
--
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
13 years, 1 month
[Hibernate-JIRA] Created: (HHH-6236) NullPointerException in org.hibernate.type.EntityType.isEqual
by Thomas Stinner (JIRA)
NullPointerException in org.hibernate.type.EntityType.isEqual
-------------------------------------------------------------
Key: HHH-6236
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6236
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.4
Environment: Hibernate 3.6.4, MySQL 5.5.8, Linux x64
Reporter: Thomas Stinner
The following error does not occur every time, but in 75% of all program starts.
The error either occurs on one of the first queries to the database, or does not occur at all.
We solve this issue by simply restarting the application and trying again. It also happens with other applications, not only this one.
INFO | jvm 1 | 2011/05/19 10:43:19 | Caused by: java.lang.NullPointerException
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.type.EntityType.isEqual(EntityType.java:344)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.type.ComponentType.isEqual(ComponentType.java:176)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.engine.CollectionKey.equals(CollectionKey.java:71)
INFO | jvm 1 | 2011/05/19 10:43:19 | at java.util.HashMap.put(HashMap.java:376)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.engine.StatefulPersistenceContext.addCollection(StatefulPersistenceContext.java:820)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.engine.StatefulPersistenceContext.addUninitializedCollection(StatefulPersistenceContext.java:789)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.type.CollectionType.getCollection(CollectionType.java:643)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.type.CollectionType.resolveKey(CollectionType.java:431)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.type.CollectionType.resolve(CollectionType.java:425)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:982)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.doQuery(Loader.java:857)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.loadEntity(Loader.java:2037)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3293)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.type.EntityType.resolve(EntityType.java:438)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:982)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.doQuery(Loader.java:857)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.doList(Loader.java:2533)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.Loader.list(Loader.java:2271)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
INFO | jvm 1 | 2011/05/19 10:43:19 | at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)
INFO | jvm 1 | 2011/05/19 10:43:19 | at de.schuechen.tms.abrechnung.RechnungenErzeugen.ausRgVorschlag(RechnungenErzeugen.java:106)
INFO | jvm 1 | 2011/05/19 10:43:19 | at de.schuechen.tms.abrechnung.RechnungenReporter.createJasperPrint(RechnungenReporter.java:136)
INFO | jvm 1 | 2011/05/19 10:43:19 | ... 5 more
STATUS | wrapper | 2011/05/19 10:43:22 | TERM trapped. Shutting down.
--
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
13 years, 1 month
[Hibernate-JIRA] Created: (HHH-5872) Methos generate in org.hibernate.id.enhanced.OptimizerFactory$PooledLoOptimizer classs is not synchronized
by Tchavdar Roussanov (JIRA)
Methos generate in org.hibernate.id.enhanced.OptimizerFactory$PooledLoOptimizer classs is not synchronized
-----------------------------------------------------------------------------------------------------------
Key: HHH-5872
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5872
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.0, 3.6.0.CR2, 3.6.0.CR1, 3.5.6, 3.6.0.Beta4, 3.6.0.Beta3, 3.5.5, 3.6.0.Beta2, 3.6.0.Beta1, 3.5.4, 3.5.3, 3.5.2
Environment: Hibernate 3.5.6-Final, Oracle 11g, WebSphere 6.1 cluster
Reporter: Tchavdar Roussanov
Receiving multiple primary key constraint violation exceptions when using SequenceStyleGenerator with optimizer parameter set to pooled-lo. Looking into the source code I found that the generate mathod for the new PooledLoOptimizer is not synchronized. After switching to PooledOptimizer (which has synchronized generate method) every thing works fine.
--
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
13 years, 1 month
[Hibernate-JIRA] Created: (HHH-5303) @Cachable has no effect
by Paul Bakker (JIRA)
@Cachable has no effect
-----------------------
Key: HHH-5303
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5303
Project: Hibernate Core
Issue Type: Bug
Components: caching (L2), entity-manager
Affects Versions: 3.5.2
Environment: Tested on HSQL (included in testcase) and MySQL database
Reporter: Paul Bakker
The JPA 2.0 @Cachable annotation has no effect at all. Just putting @Cachable on a class is not enough to enable caching. You must also configure a concurrency strategy with either @Cache or a hibernate.ejb.classcache setting in persistence.xml.
If those settings are in place, @Cacheble still has no effect. Entities are cached, but @Cachable(false) doesn't change this behavior.
I included a Maven example project that tests this behavior. The project has two profiles to switch between Hibernate and EclipseLink:
mvn -P hibernate clean test
mvn -P eclipselink clean test
--
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
13 years, 1 month
[Hibernate-JIRA] Created: (HHH-3637) Union in where doesn't works for Sybase, need to evict test case
by Juraci Paixao Krohling (JIRA)
Union in where doesn't works for Sybase, need to evict test case
----------------------------------------------------------------
Key: HHH-3637
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3637
Project: Hibernate Core
Issue Type: Improvement
Components: testsuite
Environment: Sybase ASE 15.0.2
Reporter: Juraci Paixao Krohling
Assignee: Juraci Paixao Krohling
It seems that Sybase doesn't supports UNION inside WHERE clauses, causing the test DynamicFilterTest#testSqlSyntaxOfFiltersWithUnions to fail. The scenario for this test case is not described in the documentation, but I would expect it to work:
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter....
The query is:
select
category0_.CAT_ID as CAT1_6_,
category0_.name as name6_,
category0_.eff_start_dt as eff3_6_,
category0_.eff_end_dt as eff4_6_
from
CATEGORY category0_
where
'abc' in (
select
d.reg
from
department d
where
(
d.dept_id=123
)
union
select
p.name
from
sales_person p
)
If executed only the queries from inside the where clause (the two selects with union), it works as expected. Also, if removed the union and one of the queries inside the where, it works as expected. So, the problem happens only when using union inside a where clause.
For now, I'd suggest to evict this test for Sybase.
--
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
13 years, 1 month