Hello all,
I use Hibernate version: 3.2.5.ga with dynamic maps for usage of java.lang.Map as entity-class and would like to access some legacy tables.
My xml-mapping looks like this:
Code:
<class entity-name="TEST" table="TEST">
<id name="ID" column="ID" type="long">
<generator class="sequence">
<param name="sequence">TEST_SEQ</param>
</generator>
</id>
<property name="ID2" column="ID2" type="integer" insert="false" update="true" />
<property name="STATUS" column="STATUS" type="string" />
[... some more properties ...]
<properties name="IDS" insert="false" update="false">
<property name="ID" column="ID" type="long" insert="false" update="false"/>
<property name="ID2" column="ID2" type="integer" insert="false" update="false"/>
</properties>
<map name="ATTRIBUTES" inverse="false" fetch="subselect" cascade="all" lazy="false">
<key property-ref="IDS" not-null="true">
<column name="TEST_ID" />
<column name="TEST_ID2" />
</key>
<map-key column="NAME" type="string" />
<one-to-many entity-name="TEST_ATTRIBUTE" />
</map>
</class>
<class entity-name="TEST_ATTRIBUTE" table="TEST_ATTRIBUTE">
<id name="AID" column="AID" type="long">
<generator class="sequence">
<param name="sequence">TEST_ATTRIBUTE_SEQ</param>
</generator>
</id>
<property name="ID" column="TEST_ID" insert="false" update="false" type="long" />
<property name="ID2" column="TEST_ID2" type="integer" insert="false" update="false" />
<property name="NAME" column="NAME" insert="false" update="false" type="string" />
<property name="VALUE" column="VALUE" type="string" />
</class>
I have some trouble with this:
1. After loading one TEST-entity from a database, the composed "IDS"-property contains a Map with
all other attributes of the current TEST-entity. Is this correct? I thought it has to contain a Map with only the
two entries of the properties "ID" and "ID2".
2. Using the ATTRIBUTES-map ends in a java.lang.StackOverflowError. What is wrong with it?
regards.
The stack trace:
Quote:
java.lang.StackOverflowError
at java.util.HashMap$ValueIterator.<init>(HashMap.java:869)
at java.util.HashMap$ValueIterator.<init>(HashMap.java:869)
at java.util.HashMap.newValueIterator(HashMap.java:892)
at java.util.HashMap$Values.iterator(HashMap.java:955)
at org.hibernate.impl.SessionImpl.getEnabledFilters(SessionImpl.java:1075)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.initializeCollectionFromCache(DefaultInitializeCollectionEventListener.java:82)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:48)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentMap.hashCode(PersistentMap.java:432)
at java.util.HashMap$Entry.hashCode(HashMap.java:764)
at java.util.AbstractMap.hashCode(AbstractMap.java:557)
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:112)
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:120)
at org.hibernate.engine.EntityKey.generateHashCode(EntityKey.java:104)
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:48)
at org.hibernate.persister.collection.AbstractCollectionPersister.getSubselectInitializer(AbstractCollectionPersister.java:594)
at org.hibernate.persister.collection.AbstractCollectionPersister.getAppropriateInitializer(AbstractCollectionPersister.java:574)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentMap.hashCode(PersistentMap.java:432)
at java.util.HashMap$Entry.hashCode(HashMap.java:764)
at java.util.AbstractMap.hashCode(AbstractMap.java:557)
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:112)
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:120)
at org.hibernate.engine.EntityKey.generateHashCode(EntityKey.java:104)
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:48)
at org.hibernate.persister.collection.AbstractCollectionPersister.getSubselectInitializer(AbstractCollectionPersister.java:594)
at org.hibernate.persister.collection.AbstractCollectionPersister.getAppropriateInitializer(AbstractCollectionPersister.java:574)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentMap.hashCode(PersistentMap.java:432)
at java.util.HashMap$Entry.hashCode(HashMap.java:764)
at java.util.AbstractMap.hashCode(AbstractMap.java:557)
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:112)
at org.hibernate.type.AbstractType.getHashCode(AbstractType.java:120)
at org.hibernate.engine.EntityKey.generateHashCode(EntityKey.java:104)
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:48)
...