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.