[Hibernate-JIRA] Created: (HHH-2336) UserCollectionType: add support for ParameterizedTypes and typedef'ed types to the collection-type attribute for a collection mapping
by Holger Brands (JIRA)
UserCollectionType: add support for ParameterizedTypes and typedef'ed types to the collection-type attribute for a collection mapping
-------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2336
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2336
Project: Hibernate3
Type: Improvement
Components: core
Versions: 3.2.1
Environment: Hibernate 3.2.1, independent of database platform
Reporter: Holger Brands
Attachments: usercollectionwithparameters.zip
Currently, it's required to specify a class name as value for the collection-type attribute of a collection mapping.
Therefore you can't use a typedef'ed type as collection-type and consequently you can't pass parameters to a custom collection type.
Please enhance the support for custom collection types such that you can do something like this:
<typedef name="MyEventListType" class="ca.odell.glazedlists.hibernate.EventListType">
<param name="category">Test</param>
</typedef>
<class name="User" table="`USERS`">
<id name="userName" column="USERNAME"/>
<!-- mapping a value collection -->
<list name="nickNames" table="USER_NICKNAMES"
collection-type="MyEventListType">
<key column="USER_ID"/>
<list-index column="DISPLAY_ORDER"/>
<element column="NAME" type="string" length="50"/>
</list>
</class>
Currently this mapping fails with this exception:
org.hibernate.MappingException: user colllection type class not found: MyEventListType
at org.hibernate.type.TypeFactory.customCollection(TypeFactory.java:267)
at org.hibernate.mapping.Collection.getCollectionType(Collection.java:348)
at org.hibernate.mapping.Collection.getType(Collection.java:340)
at org.hibernate.tuple.PropertyFactory.buildStandardProperty(PropertyFactory.java:120)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:163)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:425)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
at ca.odell.glazedlists.hibernate.AbstractHibernateTestCase.buildSessionFactory(AbstractHibernateTestCase.java:133)
at ca.odell.glazedlists.hibernate.AbstractHibernateTestCase.setUp(AbstractHibernateTestCase.java:167)
at junit.framework.TestCase.runBare(TestCase.java:125)
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 junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassNotFoundException: MyEventListType
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.type.TypeFactory.customCollection(TypeFactory.java:264)
... 24 more
Also see the coresponding forum entry for details:
http://forum.hibernate.org/viewtopic.php?t=969043
Attached is a test case that demonstrates this problem.
It's a modified copy of the existing "usercollection" test case in the Hibernate 3.2.1 distribution.
Just copy the directory into your org.hibernate.test directory and include it in your testsuite.
As I'm not familiar enough with the internals of Hibernate, I have no patch at hand, sorry.
Resolving this issue would enhance mapping flexibility for custom collection types because you
would be able to pass parameters as it's possible right now for UserTypes and CompositeUserTypes.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2316) org.hibernate.cache.CacheKey.equals() can cause PropertyAccessException to be thrown
by Joel Caplin (JIRA)
org.hibernate.cache.CacheKey.equals() can cause PropertyAccessException to be thrown
------------------------------------------------------------------------------------
Key: HHH-2316
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2316
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1
Environment: Windows XP / Sybase 12.5 / Java 1.5.0_09 / ehcache 1.2.4
Reporter: Joel Caplin
Priority: Critical
org.hibernate.cache.CacheKey.equals() uses lazy evaluation in its return clause: it first calls type.isEqual() and, if true, then calls entityOrRoleName.equals().
I am having difficulty reproducing this bug in the form of a test case owing to the complexity of our model and the large amount of data in question-- however, in certain circumstances, where the entityOrRoleName's are NOT equal, calling type.isEqual() yields a PropertyAccessException.
When this bug manifests itself (a PropertyAccessException is thrown), it causes ALL future Hibernate requests to throw a similar exception, thus rendering our service unusable.
This is fixed when the lazy evaluation is done the other way around: call entityOrRoleName.equals() prior to type.isEqual() - cheap string comparision vs an expensive call which has a large call tree under it.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2363) Hibernate is returning zero for the ID of a persistent object
by Archie Cobbs (JIRA)
Hibernate is returning zero for the ID of a persistent object
-------------------------------------------------------------
Key: HHH-2363
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2363
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: Hibernate 3.2.1 GA running on SuSE Linux
MySQL 4.1.13
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
Reporter: Archie Cobbs
I have two classes, {{Patient}} and {{Room}}, where {{Patient}} has a FK many-to-one reference to {{Room}}, representing a room assignment.
Both classes use a Java {{long}} field named "id" as their identifier.
When I create a Session and find a Patient with a room assignment, the Patient's identifier is correct but the Room's identifier, when accessed via {{patient.getAssignedRoom().getId()}}, is ZERO. However, in the database the value is one and {{session.getIdentifier(patient.getAssignedRoom())}} also returns one, in contradiction.
A simple reproducible test case will be attached. Instructions:
# Edit {{doit.sh}} and set {{HIBERNATE_DIR}} to point to an unpacked {{hibernate-3.2.0.ga.tar.gz}} directory
# Set {{MYSQL_CONNECTOR_JAVA}} to point to {{myslq-connector-java.jar}}
# Set {{DATABASE_USERNAME}} and {{DATABASE_PASSWORD}} if needed
# Run {{doit.sh}}.
The output I get at the end is this:
{noformat}
2037 [main] INFO org.hibernate.cache.StandardQueryCache - starting query cache at region: org.hibernate.cache.StandardQueryCache
Hibernate: select this_.id as id0_0_, this_.assignedRoom as assigned2_0_0_, this_.name as name0_0_, this_.medicalRecordNumber as medicalR4_0_0_ from Patient this_ where this_.medicalRecordNumber=?
Hibernate: select room0_.id as id1_0_, room0_.name as name1_0_ from Room room0_ where room0_.id=?
2195 [main] INFO Main - patient=Patient[Fred Example] patient.assignedRoom=Room[Room 101]
2196 [main] INFO Main - patient.id=1
2196 [main] INFO Main - patient.assignedRoom.id=0
2196 [main] ERROR Main - WTF? ID OF ROOM IS ZERO!
2196 [main] INFO Main - patient.assignedRoom.id=1
{noformat}
Note the line {{patient.assignedRoom.id=0}} ... see the corresponding code in {{Main.java}}.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2187) bad query results exposes IllegalArgumentException instead of an HibernateException
by Max Rydahl Andersen (JIRA)
bad query results exposes IllegalArgumentException instead of an HibernateException
-----------------------------------------------------------------------------------
Key: HHH-2187
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2187
Project: Hibernate3
Type: Bug
Components: query-hql
Reporter: Max Rydahl Andersen
s.createQuery("kkk");
results in an IllegalArgumentException being thrown making the exception bubble
through the expected catch HibernateException clauses in e.g. the tools.
Cause is:
public void traverseDepthFirst(AST ast) {
if ( ast == null ) {
throw new IllegalArgumentException( "node to traverse cannot be null!" );
}
visitDepthFirst( ast.getFirstChild() );
}
in NodeTraverser.
java.lang.IllegalArgumentException: node to traverse cannot be null!
at org.hibernate.hql.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:31)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at org.hibernate.console.HQLQueryPage.setSession(HQLQueryPage.java:103)
at org.hibernate.console.ConsoleConfiguration$3.execute(ConsoleConfiguration.java:309)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:304)
at org.hibernate.eclipse.hqleditor.HQLEditor.executeQuery(HQLEditor.java:374)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:72)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:52)
--
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, 8 months