-->
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: Infinite loop on bi-directional association
PostPosted: Fri Aug 04, 2006 4:18 pm 
Newbie

Joined: Mon Jul 24, 2006 4:16 pm
Posts: 7
Location: Lapland
Hi,

I am using Hibernate 3 with Spring 1.2. I have a simple one-to-many association. Lazy loading does not work for some reason (I have already asked about this in this forum and nobody seems to have a clue why), so I have set lazy=false on the "one" end of the one-to-many.

The result now is that Hibernate gets into an infinite loop of queries, alternating between the one and the many ends!

The SQL is as follows:

15:11:44,140 INFO [STDOUT] Hibernate: select environmen0_.environment_id as environm1_, environmen0_.name as name12_, environmen0_.created_on as created3_12_, environmen0_.created_by as created4_12_, environmen0_.updated_on as updated5_12_, environmen0_.updated_by as updated6_12_ from ENVIRONMENT environmen0_ where environmen0_.environment_id=?
15:11:44,296 INFO [STDOUT] Hibernate: select applicatio0_.ENVIRONMENT_ID as ENVIRONM7_1_, applicatio0_.application_id as applicat1_1_, applicatio0_.application_id as applicat1_0_, applicatio0_.name as name8_0_, applicatio0_.created_on as created3_8_0_, applicatio0_.created_by as created4_8_0_, applicatio0_.updated_on as updated5_8_0_, applicatio0_.updated_by as updated6_8_0_, applicatio0_.ENVIRONMENT_ID as ENVIRONM7_8_0_ from APPLICATION applicatio0_ where applicatio0_.ENVIRONMENT_ID=?
15:11:44,515 INFO [STDOUT] Hibernate: select environmen0_.environment_id as environm1_, environmen0_.name as name12_, environmen0_.created_on as created3_12_, environmen0_.created_by as created4_12_, environmen0_.updated_on as updated5_12_, environmen0_.updated_by as updated6_12_ from ENVIRONMENT environmen0_ where environmen0_.environment_id=?
15:11:44,531 INFO [STDOUT] Hibernate: select applicatio0_.ENVIRONMENT_ID as ENVIRONM7_1_, applicatio0_.application_id as applicat1_1_, applicatio0_.application_id as applicat1_0_, applicatio0_.name as name8_0_, applicatio0_.created_on as created3_8_0_, applicatio0_.created_by as created4_8_0_, applicatio0_.updated_on as updated5_8_0_, applicatio0_.updated_by as updated6_8_0_, applicatio0_.ENVIRONMENT_ID as ENVIRONM7_8_0_ from APPLICATION applicatio0_ where applicatio0_.ENVIRONMENT_ID=?
15:11:44,531 INFO [STDOUT] Hibernate: select environmen0_.environment_id as environm1_, environmen0_.name as name12_, environmen0_.created_on as created3_12_, environmen0_.created_by as created4_12_, environmen0_.updated_on as updated5_12_, environmen0_.updated_by as updated6_12_ from ENVIRONMENT environmen0_ where environmen0_.environment_id=?

... and so on.

The POJOs are simple beans called Environment (the one) and Application (the many), with no extra code in any of their getters or setters. I am trying to load an Environment, and get its collection of Applications, either lazily or not.

The mappings are:

Environment:

<class name="com.geai.b2b.domain.Environment" table="ENVIRONMENT">

<id name="environmentId" column="environment_id" type="long">
<generator class="sequence">
<param name="sequence">environment_id_sq</param>
</generator>
</id>

<property name="name" column="name" />
<property name="createdOn" column="created_on" />
<property name="createdBy" column="created_by" />
<property name="updatedOn" column="updated_on" />
<property name="updatedBy" column="updated_by" />

<set name="applications" table="APPLICATION" lazy="false" inverse="true">
<key column="ENVIRONMENT_ID" />
<one-to-many class="com.geai.b2b.domain.Application" />
</set>

</class>

Application:

<class name="com.geai.b2b.domain.Application" table="APPLICATION">

<id name="applicationId" column="application_id" type="long">
<generator class="sequence">
<param name="sequence">application_id_sq</param>
</generator>
</id>

<property name="name" column="name" />
<property name="createdOn" column="created_on" />
<property name="createdBy" column="created_by" />
<property name="updatedOn" column="updated_on" />
<property name="updatedBy" column="updated_by" />

<many-to-one name="environment" class="com.geai.b2b.domain.Environment" column="ENVIRONMENT_ID" lazy="true"></many-to-one>

<set name="applicationDevices" lazy="true" inverse="true">
<key column="APPLICATION_ID" />
<one-to-many class="com.geai.b2b.domain.ApplicationDevice" />
</set>

</class>

Any help is appreciated!

-Andrew

_________________
1-800-flowers.com? How on earth do you reach these people?


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.