-->
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: Dynamic Persistence - bidirectional many-to-many
PostPosted: Tue Jul 05, 2005 6:35 am 
Newbie

Joined: Thu May 05, 2005 8:31 am
Posts: 5
Location: Chennai , India
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:[/b]

version 3.0 beta 1

[b]Mapping documents:[/b]

company.hbm.xml

<hibernate-mapping>
<dynamic-class entity-name="Department">
<id name="id" column="DepartmentId" length="32" type="string">
<generator class="uuid.hex"/>
</id>
<property name="name" type="string"/>
<property name="location" type="string"/>
<bag name="employee" cascade="all-delete-orphan" inverse="false">
<key column="DepartmentId"/>
<one-to-many class="Employee"/>
</bag>
<many-to-one name="Company" column="CompanyId" class="Company" cascade="none"/>
</dynamic-class>

<dynamic-class entity-name="Employee">
<id name="id" column="EmployeeId" length="32" type="string">
<generator class="uuid.hex"/>
</id>
<property name="sn" type="string"/>
<property name="manager" type="boolean"/>
<many-to-one name="Department" column="DepartmentId" class="Department" cascade="none"/>
<bag name="Company" table="Company_employeeo" inverse="true">
<key column="EmployeeId"/>
<many-to-many class="Company" column="CompanyId"/>
</bag>
</dynamic-class>

<dynamic-class entity-name="Company">
<id name="id" column="CompanyId" length="32" type="string">
<generator class="uuid.hex"/>
</id>
<property name="name" type="string"/>
<bag name="department" cascade="all-delete-orphan" inverse="false">
<key column="CompanyId"/>
<one-to-many class="Department"/>
</bag>
<bag name="Employee" table="Company_employeeo">
<key column="CompanyId"/>
<many-to-many class="Employee" column="EmployeeId"/>
</bag>
</dynamic-class>

</hibernate-mapping>

[b]Code between sessionFactory.openSession() and session.close():[/b]

session.save("Company", (Object)map);
// map is the HashMap of objects of Company class
String id = session.getIdentifier(map).toString();

transaction.commit(); // works fine

HashMap map = (HashMap)session.get("Company", id);
// retrieves a hashmap of objects of class Company. When i parse through the map, i endup with StackOverflowException



[b]Full stack trace of any exception that occurs:[/b]
Exception in thread "main" java.lang.StackOverflowError
at java.util.AbstractList.hashCode(AbstractList.java:627)
at java.util.HashMap$Entry.hashCode(HashMap.java:710)
at java.util.AbstractMap.hashCode(AbstractMap.java:557)
at java.util.HashMap$Entry.hashCode(HashMap.java:710)
at java.util.AbstractMap.hashCode(AbstractMap.java:557)
at java.util.HashMap$Entry.hashCode(HashMap.java:710)
at java.util.AbstractMap.hashCode(AbstractMap.java:557)
at java.util.AbstractList.hashCode(AbstractList.java:630)
at java.util.HashMap$Entry.hashCode(HashMap.java:710)
at java.util.AbstractMap.hashCode(AbstractMap.java:557)
at java.util.HashMap$Entry.hashCode(HashMap.java:710)
at java.util.AbstractMap.hashCode(AbstractMap.java:557)
at java.util.HashMap$Entry.hashCode(HashMap.java:710)

[b]Name and version of the database you are using:[/b]
Oracle 9i
[b]The generated SQL (show_sql=true):[/b]
create table Employee (EmployeeId varchar2(32) not null, sn varchar2(255), manager number(1,0), DepartmentId varchar2(32), primary key (EmployeeId))

create table Company (CompanyId varchar2(32) not null, name varchar2(255), primary key (CompanyId))

create table Company_employeeo (EmployeeId varchar2(32) not null, CompanyId varchar2(32) not null)

create table Department (DepartmentId varchar2(32) not null, name varchar2(255), location varchar2(255), CompanyId varchar2(32), primary key (DepartmentId))


Can anyone tell me why i'm ending up with stackoverflowerror. Is it got something to do with the mapping.

Thanks,

Kumar Matcha.

_________________
Kumar Matcha,
Sr. Software Engineer,
OrangeScape Technologies Ltd,
Chennai - 600015.
India.
Ph: +91 - 9444012494


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.