[Hibernate-JIRA] Created: (HHH-5854) ArrayIndexOutOfBounds on fetching onetoone associations using projections
by Krishna Sundaresan (JIRA)
ArrayIndexOutOfBounds on fetching onetoone associations using projections
-------------------------------------------------------------------------
Key: HHH-5854
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5854
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.6.0
Environment: Hibernate version 3.6.0
Reporter: Krishna Sundaresan
Attachments: testCase.zip
The loading of OneToOne associations using projections results in an ArrayIndexOutOfBounds exception when the results are loaded by the CriteriaLoader.
The stacktrace is:
{code}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at org.hibernate.loader.criteria.CriteriaLoader.getResultColumnOrRow(CriteriaLoader.java:148)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:639)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at testbed.app.HibernateApp.main(HibernateApp.java:24)
Java Result: 1
{code}
The problem seems to be with the way the association aliases and types are used in getResultRow. When the types are fetched, all the types that are mentioned in the projection clause are provided whereas when the aliases to be used are fetched SimpleProjection's getColumnCount method seems to be ignoring columns that do not span resulting in a mis-match of array indices.
{code:title=From CriteriaLoader.getResultRow(...)}
if ( translator.hasProjection() ) {
Type[] types = translator.getProjectedTypes();
result = new Object[types.length];
String[] columnAliases = translator.getProjectedColumnAliases();
...
{code}
The attached file has a test-case that will demonstrate the problem. Tested that on Hibernate 3.6.0 and derby. I was able to observe this in a case where the association is mapped by a shared primary key but I guess that same should be observable even without a shared primary key.
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-6252) tests fail if change log level to trace
by Strong Liu (JIRA)
tests fail if change log level to trace
---------------------------------------
Key: HHH-6252
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6252
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.Alpha3, 3.6.4
Reporter: Strong Liu
the following tests fail (no matter what DB ) if change log level (org.hibernate) to trace:
testOrphanedWhileManaged(org.hibernate.test.orphan.one2one.fk.reversed.bidirectional.DeleteOneToOneOrphansTest)
testOrphanedWhileManaged(org.hibernate.test.orphan.one2one.fk.reversed.unidirectional.DeleteOneToOneOrphansTest)
testOrphanedWhileManaged(org.hibernate.test.orphan.one2one.fk.bidirectional.DeleteOneToOneOrphansTest)
testOrphanedWhileManaged(org.hibernate.test.orphan.one2one.pk.bidirectional.DeleteOneToOneOrphansTest)
testOrphanedWhileManaged(org.hibernate.test.orphan.one2one.pk.unidirectional.DeleteOneToOneOrphansTest)
testOrphanedWhileManaged(org.hibernate.test.orphan.one2one.fk.composite.DeleteOneToOneOrphansTest)
testCascadedDeleteOfChildOneToOne(org.hibernate.test.annotations.entity.BasicHibernateAnnotationsTest)
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-5654) query.setLockMode("alias", LockMode.LockMode.PESSIMISTIC_WRITE); does not Lock in PostgreSqlDialect
by Peter Buning (JIRA)
query.setLockMode("alias", LockMode.LockMode.PESSIMISTIC_WRITE); does not Lock in PostgreSqlDialect
---------------------------------------------------------------------------------------------------
Key: HHH-5654
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5654
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.5
Environment: Hibernate 3.5.5-Final
PostgreSQL 8.4
Reporter: Peter Buning
When you call
{{query.setLockMode("alias", LockMode.PESSIMISTIC_WRITE);}}
you get a Query with a LockOptions object that has lockMode = LockMode.NONE and a aliasSpecificLockModes-map with an entry "alias" -> LockMode.PESSIMISTIC_WRITE
When calling {{query.list()}} you get to the QueryLoader which calls {{dialect.applyLocksToSql(...)}}
The LockOptions-Object has still lockMode=LockMode.NONE and a aliasSpecificLockModes-map with the translated alias and -> LockMode.PESSIMISTIC_WRITE
As we use PostgreSQL dialect is an instance of PostgreSQLDialect.
So you get a ForUpdateFragement-object with the same LockOptions-object. The aliases-String contains the translated "alias".
In {{toFragmentString()}} {{getForUpdateString(String aliases, LockOptions lockOptions)}} is called because we have a LockOptions-object. The aliases are ignored in this case, as you can see in the comment:'by default we simply return the getForUpdateString() result since the default is to say no support for "FOR UPDATE OF ..."'
But the {{getForUpdateString(LockOptions lockOptions)}} is only looking at the the lockMode-Attribute of the LockOptions-object what has still the value "LockMode.NONE". It results in an empty String as the return value. But it should be " for update" because there's a LockMode.PESSIMISTIC_WRITE in the aliasSpecificLockModes which is ignored in getForUpdateString(LockOptions lockOptions)
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-5808) ObjectNotFoundException for an audited optional association. Envers is creating a proxy even when the association is null.
by Andrei Zagorneanu (JIRA)
ObjectNotFoundException for an audited optional association. Envers is creating a proxy even when the association is null.
--------------------------------------------------------------------------------------------------------------------------
Key: HHH-5808
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5808
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.6.0
Environment: Hibernate 3.6.0.Final, reproducible on Oracle and H2 with both EntityManager and Session
Reporter: Andrei Zagorneanu
Attachments: TestCase-Optional-Unidirectional-OneToOne.zip
Hi,
I have a Contact entity which has an optional unidirectional 1:1 association with an Address entity. Now, when I'm retrieving a version of Contact which doesn't have an Address from audit tables I can see that Address is not null, instead Envers is creating a proxy for it. When I'm trying to access that Address proxy I'm getting: org.hibernate.ObjectNotFoundException: No row with the given identifier exists
This is my entity class:
@Entity
@Audited
public class Contact {
// some fields
private Address address;
@OneToOne(cascade = { CascadeType.ALL }, orphanRemoval = true)
@JoinColumns( {
@JoinColumn(name = "ID_ADDRESS", referencedColumnName = "ID_ADDRESS"),
@JoinColumn(name = "VER_ADDRESS", referencedColumnName = "VER_ADDRESS") })
public Address getAddress() {
return this.address;
}
Now when I'm retrieving a Contact revision:
AuditReader reader = AuditReaderFactory.get(session);
Contact contact = reader.find(Contact.class, id, revision);
// here address is not null
Address address = contact.getAddress();
// here I'm getting org.hibernate.ObjectNotFoundException
address.getId();
The exception which I'm getting:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.acme.model.address.Address#com.acme.model.address.AddressPK@143fd2a[
id=<null>
ver=<null>
]]
I have to use composite PK because Address is a legacy table.
I posted this issue on Envers forum: http://community.jboss.org/thread/159906?tstart=0
The issue is reproducible while working with EntityManager and as well with Session.
I attached a TestNG test case for this.
--
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, 7 months