You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Robert S. Sfeir" <sf...@mail.nih.gov> on 2003/02/24 15:26:28 UTC

Infinite object nests after select?

I'm doing a select which in the repository has a Collection with 
auto-retrieve="true" and the table which it relates to has its own 
foreignkey pointing back to the table:

homes
	collection of brokerHomes

brokerHomes
	foreignkey homes

If I select * from brokerHomes where home_id = 1

it correctly auto retrieves the home info and the brokerHomes info... 
except there is a problem, because the homes have a collection of 
brokerHomes, it then auto retrieves the brokerHomes collection which 
contains brokerHomes object which contains the same homes object which 
containts a collection of brokerHomes... and so on and so forth.

I noticed this while debugging in IDEA and looked at the frame info, 
and noticed that I could expand the stack in that frame forever.

Is this a bug in the way I have set things up, or is this simply a 
bunch of references to the same objects?  (It doesn't look like it 
since they all have a different hash)

Thanks
R

--
Robert S. Sfeir
Senior Java Engineer
Codepuccino, Inc.
robert@codepuccino.com

definition - Codepuccino n:
A Little JSP mixed with lots of Java, usually served with Servlets, a 
Datasource, a sprinkle of XML, and sometimes EJB.  (See Great MVC 
Frameworks)


Re: Infinite object nests after select?

Posted by "Robert S. Sfeir" <sf...@mail.nih.gov>.
Ok never mind, I just looked further at the frame and from what I can 
tell you're doing something VERY cool.  Although there are a couple of 
objects duplicated, I can understand why this is, the rest of the 
references are just circular pointers.  This is very very cool actually 
because if you're looping to get data out of a nested object you can 
still pull up the reference right there without having to do any funky 
stuff.

So refresh="true" is in fact OK, and needed in some cases where I need 
to make sure the collection is updated after a new object is added or 
persisted to the DB.

NICE WORK!


On Monday, Feb 24, 2003, at 14:17 US/Eastern, Robert S. Sfeir wrote:

> See this is a catch 22 though, if I don't set refresh="true" then when 
> I insert a new object, which has a 1:n mapping, then the new object 
> doesn't show up when the page gets refreshed and I want to display it. 
>  If I set refresh="true" then everything is OK and it displays, but 
> I'm concerned about these deeply nested objects.
>
>
> On Monday, Feb 24, 2003, at 14:10 US/Eastern, Thomas Mahler wrote:
>
>> Hi Robert,
>>
>> OJB can handle cyclic structures for loading and storing.
>> non-terminating loops are avoided by looking up objects from the 
>> cache first. If you set refresh="false" (which is the default) 
>> references are not refreshed on picking up objects from the cache. By 
>> this simple mechanism we avoid recursions.
>>
>> 1. If you set refresh="true" this could end in endless recursions.
>> 2. If you use the EmptyCacheImpl this will also produce endless loops.
>>
>> cheers,
>> Thomas
>>
>> Robert S. Sfeir wrote:
>>> I'm doing a select which in the repository has a Collection with 
>>> auto-retrieve="true" and the table which it relates to has its own 
>>> foreignkey pointing back to the table:
>>> homes
>>>     collection of brokerHomes
>>> brokerHomes
>>>     foreignkey homes
>>> If I select * from brokerHomes where home_id = 1
>>> it correctly auto retrieves the home info and the brokerHomes 
>>> info... except there is a problem, because the homes have a 
>>> collection of brokerHomes, it then auto retrieves the brokerHomes 
>>> collection which contains brokerHomes object which contains the same 
>>> homes object which containts a collection of brokerHomes... and so 
>>> on and so >> forth.
>>> I noticed this while debugging in IDEA and looked at the frame info, 
>>> and noticed that I could expand the stack in that frame forever.
>>> Is this a bug in the way I have set things up, or is this simply a 
>>> bunch of references to the same objects?  (It doesn't look like it 
>>> since they all have a different hash)
>>> Thanks
>>> R
>>> -- 
>>> Robert S. Sfeir
>>> Senior Java Engineer
>>> Codepuccino, Inc.
>>> robert@codepuccino.com
>>> definition - Codepuccino n:
>>> A Little JSP mixed with lots of Java, usually served with Servlets, 
>>> a Datasource, a sprinkle of XML, and sometimes EJB.  (See Great MVC 
>>> Frameworks)
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Infinite object nests after select?

Posted by "Robert S. Sfeir" <ro...@codepuccino.com>.
See this is a catch 22 though, if I don't set refresh="true" then when 
I insert a new object, which has a 1:n mapping, then the new object 
doesn't show up when the page gets refreshed and I want to display it.  
If I set refresh="true" then everything is OK and it displays, but I'm 
concerned about these deeply nested objects.


On Monday, Feb 24, 2003, at 14:10 US/Eastern, Thomas Mahler wrote:

> Hi Robert,
>
> OJB can handle cyclic structures for loading and storing.
> non-terminating loops are avoided by looking up objects from the cache 
> first. If you set refresh="false" (which is the default) references 
> are not refreshed on picking up objects from the cache. By this simple 
> mechanism we avoid recursions.
>
> 1. If you set refresh="true" this could end in endless recursions.
> 2. If you use the EmptyCacheImpl this will also produce endless loops.
>
> cheers,
> Thomas
>
> Robert S. Sfeir wrote:
>> I'm doing a select which in the repository has a Collection with 
>> auto-retrieve="true" and the table which it relates to has its own 
>> foreignkey pointing back to the table:
>> homes
>>     collection of brokerHomes
>> brokerHomes
>>     foreignkey homes
>> If I select * from brokerHomes where home_id = 1
>> it correctly auto retrieves the home info and the brokerHomes info... 
>> except there is a problem, because the homes have a collection of 
>> brokerHomes, it then auto retrieves the brokerHomes collection which 
>> contains brokerHomes object which contains the same homes object 
>> which containts a collection of brokerHomes... and so on and so >> forth.
>> I noticed this while debugging in IDEA and looked at the frame info, 
>> and noticed that I could expand the stack in that frame forever.
>> Is this a bug in the way I have set things up, or is this simply a 
>> bunch of references to the same objects?  (It doesn't look like it 
>> since they all have a different hash)
>> Thanks
>> R
>> -- 
>> Robert S. Sfeir
>> Senior Java Engineer
>> Codepuccino, Inc.
>> robert@codepuccino.com
>> definition - Codepuccino n:
>> A Little JSP mixed with lots of Java, usually served with Servlets, a 
>> Datasource, a sprinkle of XML, and sometimes EJB.  (See Great MVC 
>> Frameworks)
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Infinite object nests after select?

Posted by Thomas Mahler <th...@web.de>.
Hi Robert,

OJB can handle cyclic structures for loading and storing.
non-terminating loops are avoided by looking up objects from the cache 
first. If you set refresh="false" (which is the default) references are 
not refreshed on picking up objects from the cache. By this simple 
mechanism we avoid recursions.

1. If you set refresh="true" this could end in endless recursions.
2. If you use the EmptyCacheImpl this will also produce endless loops.

cheers,
Thomas

Robert S. Sfeir wrote:
> I'm doing a select which in the repository has a Collection with 
> auto-retrieve="true" and the table which it relates to has its own 
> foreignkey pointing back to the table:
> 
> homes
>     collection of brokerHomes
> 
> brokerHomes
>     foreignkey homes
> 
> If I select * from brokerHomes where home_id = 1
> 
> it correctly auto retrieves the home info and the brokerHomes info... 
> except there is a problem, because the homes have a collection of 
> brokerHomes, it then auto retrieves the brokerHomes collection which 
> contains brokerHomes object which contains the same homes object which 
> containts a collection of brokerHomes... and so on and so forth.
> 
> I noticed this while debugging in IDEA and looked at the frame info, and 
> noticed that I could expand the stack in that frame forever.
> 
> Is this a bug in the way I have set things up, or is this simply a bunch 
> of references to the same objects?  (It doesn't look like it since they 
> all have a different hash)
> 
> Thanks
> R
> 
> -- 
> Robert S. Sfeir
> Senior Java Engineer
> Codepuccino, Inc.
> robert@codepuccino.com
> 
> definition - Codepuccino n:
> A Little JSP mixed with lots of Java, usually served with Servlets, a 
> Datasource, a sprinkle of XML, and sometimes EJB.  (See Great MVC 
> Frameworks)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>