[Hibernate-JIRA] Created: (HHH-4959) Concurrent HQL parsing blocks on ReflectHelper.classForName()
by Jarl Totland (JIRA)
Concurrent HQL parsing blocks on ReflectHelper.classForName()
-------------------------------------------------------------
Key: HHH-4959
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4959
Project: Hibernate Core
Issue Type: Improvement
Components: query-hql
Affects Versions: 3.3.2
Environment: DB2
Reporter: Jarl Totland
Priority: Minor
Attachments: ReflectHelper.java
For particularly HQL-heavy applications, concurrency is lost as ReflectHelper.classForName() blithely runs loadClass() for tokens again and again, many of which are not even classes. As loadClass() is synchronized it end up blocking while it generates stacktraces for its exceptions. This goes for both classic and AST parsers.
Because of this blocking our regression tests took over 20 minutes, regardless of number of threads.
Implementing a simple cache from String to Class in ReflectHelper.classForName() reduced this to 3 minutes for eight threads on a dual-core cpu; the bottleneck is now the database as it should be, not lock contention.
The issue was reported earlier in HHH-1810, but dismissed as related to the classic parser only.
We might use HQL in inappropriate ways, but still wouldn't hurt for Hibernate to support this.
Attached is our modified ReflectHelper; modified code is in the classForName()-methods, classForNameInternal(), and the static HashMap<String, Object> classes.
--
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
12 years, 5 months
[Hibernate-JIRA] Created: (HHH-5274) HQL-Insert with Select and Sub-Select fails
by Björn Moritz (JIRA)
HQL-Insert with Select and Sub-Select fails
-------------------------------------------
Key: HHH-5274
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5274
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.2
Environment: Hibernate 3.5.2, Oracle 10 (using org.hibernate.dialect.Oracle10gDialect)
Reporter: Björn Moritz
Attachments: Testcase.zip
In Hibernate 3.5.2 a HQL-Insert statement doing a select using a subselect is failing. This is due to a wrong replacement of the table name in the generated SQL-Statement.
The following statement will work:
{code:sql}select a.id from A a where exists (select 1 from B b where b.id = a.id){code}
but an insert statement embedding the same statement does not work:
{code:sql}insert into C (id) select a.id from A a where exists (select 1 from B b where b.id = a.id){code}
The latter statement will thrown an SqlSyntaxErrorException as the second 'a.id' will get replaced with 'AAA.id' (which is the real table name and not the alias used in the generated sql statement).
In Hibernate 3.1.3 both statements worked 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
12 years, 5 months
[Hibernate-JIRA] Created: (HHH-6662) @AssociationOverride with @JoinTable does not work
by Richard Kohl (JIRA)
@AssociationOverride with @JoinTable does not work
--------------------------------------------------
Key: HHH-6662
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6662
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.7
Environment: Hibernate 3.6.7.Final
Reporter: Richard Kohl
Priority: Critical
Attachments: test-case.zip
@AssociationOverride is completely ignored when used with @JoinTable (test case encloded, but it will probably happen always).
I looked through the Hibernate code and that reason for that is probably the typo in org.hibernate.cfg.AbstractPropertyHolder.buildHierarchyColumnOverride(XClass), particulary lines:
currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses
currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
Instead, the should be:
currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses
currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses
currentJoinTableOverride.putAll( joinTableOverride); //subclasses have precedence over superclasses
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 5 months
[Hibernate-JIRA] Created: (HHH-6100) Bug fix related to CriteriaQuery (JPA) when using XML mappings
by JOUFFRE Nelly (JIRA)
Bug fix related to CriteriaQuery (JPA) when using XML mappings
--------------------------------------------------------------
Key: HHH-6100
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6100
Project: Hibernate Core
Issue Type: Patch
Affects Versions: 3.6.2
Environment: hibernate-(core, entitymanager...)-3.6.2.Final
hibernate-jpa-2.0-api-1.0.0.Final
MySQL 5.1
Spring 3.0.5.RELEASE
Reporter: JOUFFRE Nelly
Priority: Critical
Hi,
I use XML mapping and wanted to implement the following query using CriteriaQuery.
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<MyClass> cq = cb.createQuery(MyClass.class);
Root<MyClass> objRoot = cq.from(MyClass.class);
List<MyClass> results = entityManager.createQuery(cq).getResultList();
(Actually my query is more complex than that but it was the first step.)
The first bug was that query generated the following jpql
select generatedAlias0 from null as generatedAlias0
This was because the org.hibernate.mapping.PersistentClass.jpaEntityName attribute was not set
Once I fixed it if tried to add a WHERE clause which was
cq.where(cb.equal(objRoot.get("embeddablePkId").get("embeddablePkIdAttribute"), "valueToSearch"));
which resulted into a NullPointerException because the org.hibernate.mapping.RootClass.declaredIdentifierProperty attribute was not set for simple and embeddable PK
Theses 2 attributes are well set but only when using annotation mappings because they are set via the AnnotationBinder.
In my case, with XML mapping, it calls the HbmBinder so these attributes are never set.
Here are my bug fixes, hope this help.
Cheers,
$ git diff
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java b/hib
index dd0e14a..4cacb8e 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java
@@ -451,6 +451,7 @@ public final class HbmBinder {
prop.setValue( id );
bindProperty( idNode, prop, mappings, inheritedMetas );
entity.setIdentifierProperty( prop );
+ entity.setDeclaredIdentifierProperty( prop );
}
// TODO:
@@ -484,6 +485,7 @@ public final class HbmBinder {
prop.setValue( id );
bindProperty( idNode, prop, mappings, inheritedMetas );
entity.setIdentifierProperty( prop );
+ entity.setDeclaredIdentifierProperty( prop );
}
makeIdentifier( idNode, id, mappings );
@@ -564,6 +566,7 @@ public final class HbmBinder {
throw new MappingException( "Unable to determine entity
}
persistentClass.setEntityName( entityName );
+ persistentClass.setJpaEntityName( entityName );
bindPojoRepresentation( node, persistentClass, mappings, inherit
bindDom4jRepresentation( node, persistentClass, mappings, inheri
(END)
--
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
12 years, 5 months
[Hibernate-JIRA] Created: (HHH-6204) JoinColumn on non key field fails to populate collection
by Chris Sams (JIRA)
JoinColumn on non key field fails to populate collection
--------------------------------------------------------
Key: HHH-6204
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6204
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.Alpha3, 3.6.4, 4.0.0.Alpha2, 3.6.3, 4.0.0.Alpha1, 3.6.2, 3.6.1, 3.6.0, 3.6.0.CR2, 3.6.0.CR1, 3.6.0.Beta4, 3.6.0.Beta3, 3.6.0.Beta2, 3.6.0.Beta1, 3.3.2
Environment: EAP 5 (hibernate 3.3.2), hibernate 3.6.x, 4.0.x , probably eap4 as well
Reporter: Chris Sams
Attachments: CompositeKeyExample.zip
To duplicate the issue, create three tables in a database with no declared primary or foreign keys. Map entities to two of the tables. One of these entities has a primitive @Id; the other has an @EmbeddedId. Both entities contain an additional field used to join with the third table and populate a collection.
This works with the entity that has a primitive @Id but for the entity with @EmbeddedId, trying to do anything with the collection after calling the getter results in:
javax.ejb.EJBException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of jboss.example.DoesNotWorkPk.id1
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
....
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of jboss.example.DoesNotWorkPk.id1
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:58)
....
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field jboss.example.DoesNotWorkPk.id1 to jboss.example.DoesNotWork
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
I've attached a sample project. The relevant files are Works.java, DoesNotWork.java, and DoesNotWorkPk.java
There's also data.sql along with the java files to populate a mysql db, but I think any DB will do.
--
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
12 years, 5 months
[Hibernate-JIRA] Created: (HHH-2851) ParameterTranslationsImpl fails to correctly determine parameter type
by Alex Savitsky (JIRA)
ParameterTranslationsImpl fails to correctly determine parameter type
---------------------------------------------------------------------
Key: HHH-2851
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2851
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5
Reporter: Alex Savitsky
Priority: Minor
For the conditions in the form "(:param IS NULL OR alias.someField = :param)", the HQL parses would not correctly determine the type of param, unless the conditions are swapped like "(alias.someField = :param OR :param IS NULL)". The reason is that NamedParamTempHolder classes are created for all parameter entries, in the order they appear in the query. The first occurrence (:param IS NULL) would have its expectedType set to null, and the second occurrence would use the param holder created by the first occurrence, without checking whether it can improve it in any way (which it can - the expectedType for second occurrence is correctly determined to be Long).
Proposed fix would be to check for this particular condition, enhancing paramHolder if possible, with new information:
old code:
if ( paramHolder == null ) {
paramHolder = new NamedParamTempHolder();
paramHolder.name = namedSpec.getName();
paramHolder.type = namedSpec.getExpectedType();
namedParameterMap.put( namedSpec.getName(), paramHolder );
}
new code:
if ( paramHolder == null ) {
paramHolder = new NamedParamTempHolder();
paramHolder.name = namedSpec.getName();
paramHolder.type = namedSpec.getExpectedType();
namedParameterMap.put( namedSpec.getName(), paramHolder );
+ } else if (paramHolder.getExpectedType() == null && namedSpec.getExpectedType() != null) {
+ paramHolder.type = namedSpec.getExpectedType();
}
--
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
12 years, 5 months