Hibernate, Dataview and joining two classes (tables)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Hibernate, Dataview and joining two classes (tables)

nebojsa.nedic
Hello all,

I am using Hibernate, Dataview, and I would like to show list objects in dataview.

List of objects has an reference to another class with list of details for each object. In order to communicate it easily, I would give an example:

Class Client...
   ...
   private Set<Address> address = new LinkedHashSet<Address>();
   ...

this is connected in hibernate like
....
<set
  name="address"
        fetch="join"
        cascade="save-update"
        order-by="addressName">
        <key
                column="Client_ID"
                foreign-key="FK_ADDRESS_CLIENT_ID"/>
                <one-to-many class="model/stakeholdersPartners.Address"/>
</set>
....

Now I have one issue. When I pass this list of objects to dataview it is presented in a way that one client is repeated number of times that is equivalent to the number of addresses it has. This is due to "join" type of fetch type / how I understood it.

I have few ideas how to solve this, but non of the ideas I don't like, and I don't know what is the best practice to handle this.

I don't know what is the best practice here and how to handle it? Any ideas?

All the best.