[Hibernate-JIRA] Created: (HHH-2598) Mapping a collection of entities from two different classes with the same collection name results in duplicate backref property exception if collection keys are not null
by Guido Scalise (JIRA)
Mapping a collection of entities from two different classes with the same collection name results in duplicate backref property exception if collection keys are not null
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2598
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2598
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3, 3.2.2, 3.2.1
Environment: Proven on Hibernate 3.2.2 and 3.2.3, PostgreSQL 8.2.3, WindowsXP, Java 1.5
Reporter: Guido Scalise
Attachments: backref.patch, Hibernate-bug.zip
Mapping a child entity collection from two different parent entities results in duplicate backref property exception when configuring the session factory if the collection keys are marked not null and the collection names are the same in both parents.
Log is:
(cfg.Environment 509 ) Hibernate 3.2.3
(cfg.Environment 542 ) hibernate.properties not found
(cfg.Environment 676 ) Bytecode provider name : cglib
(cfg.Environment 593 ) using JDK 1.4 java.sql.Timestamp handling
(cfg.Configuration 1426) configuring from resource: /hibernate.cfg.xml
(cfg.Configuration 1403) Configuration resource: /hibernate.cfg.xml
(cfg.Configuration 553 ) Reading mappings from resource : com/bbsw/tests/ParentA.hbm.xml
(cfg.HbmBinder 300 ) Mapping class: com.bbsw.tests.ParentA -> PARENT_A
(cfg.Configuration 553 ) Reading mappings from resource : com/bbsw/tests/ParentB.hbm.xml
(cfg.HbmBinder 300 ) Mapping class: com.bbsw.tests.ParentB -> PARENT_B
(cfg.Configuration 553 ) Reading mappings from resource : com/bbsw/tests/Child.hbm.xml
(cfg.HbmBinder 300 ) Mapping class: com.bbsw.tests.Child -> CHILD
(cfg.Configuration 1541) Configured SessionFactory: null
(cfg.HbmBinder 2375) Mapping collection: com.bbsw.tests.ParentA.children -> CHILD
(cfg.HbmBinder 2375) Mapping collection: com.bbsw.tests.ParentB.children -> CHILD
Exception in thread "main" org.hibernate.MappingException: Duplicate property mapping of _childrenBackref found in com.bbsw.tests.Child
at org.hibernate.mapping.PersistentClass.checkPropertyDuplication(PersistentClass.java:459)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:449)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at HBTest.main(HBTest.java:17)
The problem seems to be originated during the second Collection binding pass in org.hibernate.cfg.HbmBinder, as the Backrefs and IndexBackrefs names are created like this:
(Excerpts from HbmBinder.java r10921 2006-12-05 14:39:12Z steve.ebersole(a)jboss.com, contained in the Hibernate 3.2.3.ga source)
line 2242: IndexBackref ib = new IndexBackref();
line 2243: ib.setName( '_' + node.attributeValue( "name" ) + "IndexBackref" );
and
line 2478: Backref prop = new Backref();
line 2479: prop.setName( '_' + node.attributeValue( "name" ) + "Backref" );
in both cases the node name value is the collection name. So for every collection that points to a child, Hibernate creates a backref property without considering the posibility of more than one entity declaring the same collection name.
I've patched the code to add the collection owner's entity name to the property name, and it worked without problems.
I'm attaching:
* ParentA, ParentB and Child classes
* Mappings for ParentA, ParentB and Child
* hbm.xml file
* Main test case. (HBTest.java)
* Proposed patch in unified diff format.
--
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
17 years, 3 months
[Hibernate-JIRA] Created: (HHH-2734) PreparedStatement leak with lazy properties
by Christian Gruber (JIRA)
PreparedStatement leak with lazy properties
-------------------------------------------
Key: HHH-2734
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2734
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4
Environment: Hibernate 3.2.4
Oracle 10g
Sun Java 1.5.0
Reporter: Christian Gruber
Priority: Critical
Hello!
When iterating through more than 300 elements that have lazy properties, I get an ORA-01000 JDBC error ("maximum open cursors exceeded"). I found out that the root cause for this are unclosed prepared statements in AbstractBatcher.prepareSelectStatement(String). When I add the generated prepared statement to the statementsToClose set in this method, the problem vanishes. But I don't have an idea what other effects this might have, and why the prepared statement was not added to the statements to close in the first place.
How to reproduce:
- Make a class with at least one lazy property; instrument the byte code
- Create an Oracle database with at least 300 entries in the table for this class
- Execute the following code:
Iterator<MyClass> it = session.createQuery("from MyClass mc").iterate();
while (it.hasNext()) {
MyClass mc = it.next();
String la = mc.getLazyAttribute();
session.evict(mc);
}
- Watch the log for org.hibernate.jdbc.AbstractBatcher entries containing
"about to open ResultSet" and see the numbers increase
As already mentioned, a simple fix for this is adding "statementsToClose.add( ps );" into AbstractBatcher.java, around line 133 (assigning the PreparedStatement to a new variable "ps" first, of course), but as I don't understand the differences between the various PreparedStatement generating methods there, that might give rise to other problems.
Thanks for looking at it,
Christian
--
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
17 years, 3 months
[Hibernate-JIRA] Created: (HHH-2593) Keyword UNION is prefixed with "this_." in filter conditions
by Frederic Leitenberger (JIRA)
Keyword UNION is prefixed with "this_." in filter conditions
------------------------------------------------------------
Key: HHH-2593
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2593
Project: Hibernate3
Issue Type: Bug
Components: query-hql, query-sql
Affects Versions: 3.2.1
Environment: Oracle 10g: org.hibernate.dialect.OracleDialect
Suse Linux
Hibernate: 3.2.1.ga
Hibernate Annotations: 3.2.1.GA
Reporter: Frederic Leitenberger
Priority: Trivial
I need to use a UNION-Subquery in a Filter condition unless HHH-298 is solved.
But anyway, when using the keyword "union" in the Filter condition it is prefixed with "this_.".
For instance, this ...
@Filter(name = "resellerFilter", condition = "(select cu.resellerId from Customer cu, GeoNumber gn where (cu.id = gn.customerId and gn.id = this_.geoNumberId) UNION select cu.resellerId from Customer cu where cu.detemeTemplateId = this_.id) in (null, :resellerIds)")
... produces this ...
select
...
from
DeTeMe this_
where
(
select
cu.resellerId
from
Customer cu,
GeoNumber gn
where
(
cu.id = gn.customerId
and gn.id = this_.geoNumberId
) this_.UNION select
cu.resellerId
from
Customer cu
where
cu.detemeTemplateId = this_.id
) in (
null, ?
)
and this_.id = ?
--
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
17 years, 3 months
[Hibernate-JIRA] Created: (HHH-2750) Oracle9i dialect do not support SequenceStyleGenerator
by Richard Lee (JIRA)
Oracle9i dialect do not support SequenceStyleGenerator
------------------------------------------------------
Key: HHH-2750
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2750
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3
Environment: Oracle9i
Reporter: Richard Lee
Attachments: dynamicMap.hbm.xml
In the hibernate.cfg.xml set :
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hbm2ddl.auto">update</property>
Java Code:
private void createSubnet() {
Session session = HibernateSessionFactory.getSession();
HashMap<String, Object> subNet = new HashMap<String, Object>();
subNet.put("ISDELETE", Boolean.FALSE);
Timestamp now = DateUtil.getNow();
subNet.put("CREATE_TIME", now);
subNet.put("LAST_MODIFY_TIME", now);
Transaction tx = session.beginTransaction();
session.save("SUB_NET", subNet);
tx.commit();
session.flush();
HibernateSessionFactory.closeSession();
}
Exception:
Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.dialect.Dialect.getCreateSequenceStrings(Ljava/lang/String;II)[Ljava/lang/String;
at org.hibernate.id.enhanced.SequenceStructure.sqlCreateStrings(SequenceStructure.java:97)
at org.hibernate.id.enhanced.SequenceStyleGenerator.sqlCreateStrings(SequenceStyleGenerator.java:168)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:1051)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:140)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
at com.ultrapower.oe.util.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:89)
at com.ultrapower.oe.util.HibernateSessionFactory.getSession(HibernateSessionFactory.java:63)
--
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
17 years, 3 months
[Hibernate-JIRA] Created: (HHH-2813) CacheableFileTest Failing Because Mapping File Doesn't Exist
by James Carman (JIRA)
CacheableFileTest Failing Because Mapping File Doesn't Exist
------------------------------------------------------------
Key: HHH-2813
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2813
Project: Hibernate3
Issue Type: Bug
Components: testsuite
Reporter: James Carman
Attachments: CacheaableFileTest.patch
When running the test suite from a fresh trunk checkout, I get one little failing test in the maven 2 based build:
junit.framework.AssertionFailedError
at org.hibernate.test.cfg.CacheableFileTest.setUp(CacheableFileTest.java:26)
at org.hibernate.junit.UnitTestCase.runBare(UnitTestCase.java:34)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
I changed the code just a bit (patch attached) to get it to work. This could be a platform issue (I'm on Windows XP Pro SP2), but it'd be nice if it worked on all platforms. Here's what I changed so you don't have to open the patch:
mappingFile = new File( getClass().getClassLoader().getResource( MAPPING ).getFile() );
changes to:
mappingFile = new File( getClass().getClassLoader().getResource( MAPPING ).toURI() );
--
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
17 years, 3 months