These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problems with map in dynamic Map-entity
PostPosted: Mon Feb 04, 2008 1:26 pm 
Newbie

Joined: Mon Sep 10, 2007 9:30 am
Posts: 12
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)

...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.