« Return to Thread: how to get linked collections from Hibernate to the client

Re: how to get linked collections from Hibernate to the client

by martin krüger-5 :: Rate this Message:

Reply to Author | View in Thread

Hi Josh,

thanks a lot for the tip with
Hibernate.initialize()
It works like a charm. Only for many-to-many i have to think of something else.But that's not really the problem.

Greetings Martin

2008/5/7 Josh Holtzman <jholtzman@...>:
I had run into a similar issue when I was serializing hibernate proxies.  I now avoid sending these proxies to the client for a variety of reasons, but if you're sure that you want to do this, you have a couple of options that I know of:

1) Manually initialize the proxies that you want access to in the client.  In other words, loop through each folder and each sheet on the server, calling sheet.getTags().
2) Call Hibernate.initialize() on each folder object.  I've found that this will recurse into all of the fields on the proxy, but according to the API it isn't guaranteed to navigate the entire object graph, so you may need to loop through all of the sheet objects anyway.


Good luck,
Josh


martin krüger wrote:
Hi everybody,

I'm getting a little headache at the moment because of my little test project. I'm writing a small test application using Hibernate and since yesterday also DWR. I already managed to request Collections from Hibernate and display them on the client with this lines:

<convert converter="hibernate3" match="com.topdesk.training.accounting.hibernate.pojos.Tag" />
<convert converter="collection" match="java.util.Collection"/>

The problem now is that i have in some POJOS collections of other POJOS.

example:
1 folder has zero or more sheets
1 sheet has zero or more tags
(which are stored in a collection)

When i request all sheets from the server i return a collection of sheets. That works perfectly. I want to display all sheets in a simple HTML table. Per sheet i also want to list all tags that belong to that sheet. The problem now is that the collection that holds all the tags per sheet is null. Is there another way (another option) that i missed to let DWR also return the collections that belong to one object?

Thanks a lot already for DWR. It's a really nice tool.


 « Return to Thread: how to get linked collections from Hibernate to the client