Hi,
I'm trying to make a query that looks at certain values in a map. For example the map could contain:
key;"key" value:"value"
And then I want to include the value in an equals expression. This works using Criteria.createCriteria() when the association is another class, but I can't get it to work with a map as mapped below. Any Ideas?
Thanks in advance,
Ivo
Hibernate version: 3.1.3
Mapping documents:
Code:
<hibernate-mapping package="org.openprojectservices">
<class name="Event" table="event">
<!-- left the rest out -->
<map name="xProps" cascade="all" table="event_xProps" order-by="xprop_name" lazy="false">
<key column="id"/>
<map-key column="xprop_name" type="string"/>
<element column="xprop_value" type="string"/>
</map>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Criteria criteria = getSession().createCriteria(Event.class);
Criteria xPropsCriteria = criteria.createCriteria("xProps");
Full stack trace of any exception that occurs:Code:
org.hibernate.MappingException: collection was not an association: org.openprojectservices.Event.xProps
at org.hibernate.type.CollectionType.getAssociatedEntityName(CollectionType.java:380)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getPathEntityName(CriteriaQueryTranslator.java:207)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.createCriteriaEntityNameMap(CriteriaQueryTranslator.java:191)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.<init>(CriteriaQueryTranslator.java:81)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:58)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1514)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.openprojectservices.dao.impl.EventDaoHibernateImpl.getEvents(EventDaoHibernateImpl.java:29)
at org.webical.dao.EventDaoHibernateimplTest.testGetEventsForProjectGUIDList(EventDaoHibernateimplTest.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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)
Name and version of the database you are using:
HSQLDB 1.8.0