[Hibernate-JIRA] Created: (HHH-2470) Use of session.createSQLQuery causes memory leak
by Bjørn Bjerkeli (JIRA)
Use of session.createSQLQuery causes memory leak
-------------------------------------------------
Key: HHH-2470
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2470
Project: Hibernate3
Type: Bug
Components: query-sql
Versions: 3.1.3
Environment: Win XP, Oracle 10g, Java 1.4.2
Reporter: Bjørn Bjerkeli
Attachments: TestCase.zip
NativeSQLQuerySpecification fails to properly implement equals and hashcode caused by lacking implementation of hashCode and equals in all SQLQueryReturn implementations and SQLQueryScalarReturn which are members of NativeSQLQuerySpecification. I can see that NativeSQLQuerySpecification has been changed in 3.2, but the problem is still there.
NativeSQLQuerySpecification instances are used as keys for retrieving and caching NativeSQLQueryPlan instances.
This causes the caching-mechanism to be pretty useless when Queries created by session.createSQLQuery because new entries will be added all the time in the QueryPlanCache and the SoftLimitMRUCache member.
So far so good, the more serious problem that is caused by this is stems from the implementation of SoftLimitMRUCache which again uses LRUMap in commons-collection. The put - method of the cache is not treadsafe, and that causes the following fragment in LRUMap to allow the map to grow beyond its maximumSize. That is bacause the containsKey method will return an incorrect result when concurrently updating the map.
public Object put( Object key, Object value ) {
int mapSize = size();
Object retval = null;
if ( mapSize >= maximumSize ) {
// don't retire LRU if you are just
// updating an existing key
if (!containsKey(key)) {
// lets retire the least recently used item in the cache
removeLRU();
}
}
retval = super.put(key,value);
return retval;
}
I have included a test-case that demonstrates:
1) Wrong implementation of equals and hashCode in NativeSQLQuerySpecification
2) Concurrent use of LRUMap causes the map to grow beyound it's max limit
3) Concurrent execution of session.createSQLQuery causes memory leak due to 1) and 2)
I would be more than happy to contribute to get this fixed. Just let me know.
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-3221) Cascading performance problems when session contains many entities
by Yves Galante (JIRA)
Cascading performance problems when session contains many entities
------------------------------------------------------------------
Key: HHH-3221
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3221
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.3.0.CR1, 3.2.6, 3.2.5
Reporter: Yves Galante
Attachments: patchCascading.patch, SaveTest.zip
When session contains many entities, performence of cascading become very slow.
For each collection element the whole persistence context is searched (by StatefulPersistenceContext#getIndexInOwner() and StatefulPersistenceContext#getOwnerId) and its even searched twice when the collection is an indexed collection.
This patch optimize cascading operation by caching relation parent-child on a map.
eventSource.getPersistenceContext().addChildParent(child, parent);
action.cascade(eventSource, child, entityName, anything, isCascadeDeleteEnabled);
eventSource.getPersistenceContext().removeChildParent(child);
The test case save and flush 10 * 551 objects.
Before patch save object with cascading is more slow when session size grows.
After patch time of save stay same at each loop.
Output of the test case before the patch :
Save took 449 ms
Save took 669 ms
Save took 1042 ms
Save took 1464 ms
Save took 2481 ms
Save took 2741 ms
Save took 3807 ms
Save took 4344 ms
Save took 4975 ms
Save took 5251 ms
Total took 30906 ms
Output after the patch
Save took 445 ms
Save took 144 ms
Save took 164 ms
Save took 108 ms
Save took 93 ms
Save took 93 ms
Save took 93 ms
Save took 94 ms
Save took 91 ms
Save took 89 ms
Total took 4905 ms
--
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, 4 months
[Hibernate-JIRA] Created: (ANN-793) @ManyToOne - @OneToMany doesn't work with @Inheritance(strategy= InheritanceType.JOINED)
by Tomaz Cerar (JIRA)
@ManyToOne - @OneToMany doesn't work with @Inheritance(strategy= InheritanceType.JOINED)
----------------------------------------------------------------------------------------
Key: ANN-793
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-793
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.4.0.GA
Environment:
Hibernate Core 3.3.1.GA
Hibernate Annotations 3.4.0 GA
Hibernate EntityManager 3.4.0 GA
Jboss 4.3 EAP,
DB2 9.5
Reporter: Tomaz Cerar
I am trying to create bidirectional association between two entities in which one can be Inherited and it fails with table not found:
11:37:39,229 ERROR [AssertionFailure] [] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: Table CRM.CRM_AKTIVNOST_DOGODKI not found
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(JoinedSubclassEntityPersister.java:480)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:259)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:87)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:261)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)
at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
The code looks like this:
@Entity
@Table(name = "CRM_AKTIVNOST")
public class Aktivnost implements Serializable {
private List<Dogodek> dogodki;
....
....
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL,mappedBy = "aktivnost")
public List<Dogodek> getDogodki() {
return dogodki;
}
public void setDogodki(List<Dogodek> dogodki) {
this.dogodki = dogodki;
}
...
...
}
@Entity
@Table(name = "CRM_DOGODEK")
@Inheritance(strategy= InheritanceType.JOINED)
public class Dogodek implements Serializable {
...
...
private Aktivnost aktivnost;
....
....
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "CRM_AKTIVNOST_DOGODKI", joinColumns = {@JoinColumn(name = "DOGODEK_ID")}, inverseJoinColumns = {@JoinColumn(name = "AKTIVNOST_ID")})
public Aktivnost getAktivnost() {
return aktivnost;
}
public void setAktivnost(Aktivnost aktivnost) {
this.aktivnost = aktivnost;
}
...
}
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-4647) Problems with @JoinColumn referencedColumnName and quoted column and table names
by Peter Brant (JIRA)
Problems with @JoinColumn referencedColumnName and quoted column and table names
--------------------------------------------------------------------------------
Key: HHH-4647
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4647
Project: Hibernate Core
Issue Type: Bug
Components: annotations, core
Affects Versions: 3.5.0-Beta-2
Environment: current CVS, not database platform dependent
Reporter: Peter Brant
Attachments: hibernate-annotations.patch, hibernate-core.patch, test-case.zip
There are really two separate issues here, but the test case reduction and patches are so small (and involve related functionality) they are combined.
#1: A referencedColumnName that references a quoted target column cannot be found. The test case is app.TestReferencedColumnName#testQuotedReferencedColumnName(). The patch is hibernate-annotations.patch.
#2: An invalid referencedColumnName (including the unquoted version of a valid column) results in an infinite loop in o.h.c.Configuration$MappingsImpl#getPhysicalColumnName(). The test case is app.TestReferencedColumnName#testInvalidReferencedColumnNameOnQuotedTable. The patch is hibernate-core.patch. It looks like the same issue exists with getLogicalColumnName(), but I'm not sure where this is used (i.e. how to test it) so I left it alone.
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-3909) Improve Performance of FieldInterceptionHandler (and thus of flushing)
by Ovidio Mallo (JIRA)
Improve Performance of FieldInterceptionHandler (and thus of flushing)
----------------------------------------------------------------------
Key: HHH-3909
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3909
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.3.1
Reporter: Ovidio Mallo
Attachments: patch.txt
In the FieldInterceptionHelper class, the method Class#getInterfaces() is used in conjunction with a subsequent loop over all interfaces of an entity class in order to check whether a bytecode instrumentation interface of CGlib or Javassist is found. This is done that way since CGlib and Javassist are both optional so they should only be accessed at runtime if available on the classpath. Attached you can find a simple patch which only once checks whether CGlib and/or Javassist is available and then uses the more performant "instanceof" operator in order to check whether an entity has an interceptor. The new code still guarantees that no CGlib or Javassist class is accessed if it is not on the classpath.
The patch helps making the FieldInterceptionHelper methods more performant which can e.g. be noticed during a session flush, especially if bytecode instrumentation is used. In order to measure the performance impact of the patch I've written a simple program which does the following:
1. insert 100 thousand entities into a simple table with 6 numeric attributes
2. do an initial flush on the session in order to execute all the insert statements
3. loop 300 times and do a flush on the session (only a dirty check is performed, no database operation)
I've time the flushes under point 3 above with and without bytecode instrumentation for the used entity. Here are the results:
USING BYTECODE INSTRUMENTATION
=============================
* SUN JVM 1.6.0_05:
- without patch: 25734ms
- with patch: 11015ms
* IBM JVM 1.4.2:
- without patch: 20672ms
- with patch: 11140ms
WITHOUT BYTECODE INSTRUMENTATION
================================
* SUN JVM 1.6.0_05:
- without patch: 73328ms
- with patch: 62015ms
* IBM JVM 1.4.2:
- without patch: 70344ms
- with patch: 61125ms
Using bytecode instrumentation, the performance improvement is about of a factor of 2-2.5. When not using bytecode instrumentation, the overall impact is of course less relevant since the rest of the work done during flush is more expensive anyway. In any case, IMHO the impact when using bytecode instrumentation is relevant.
The patch is very simple and only touches the FieldInterceptionHelper class.
--
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, 4 months