mmerder wrote:
An entity like DogSelection could be a solution. Do you use a join-table or a join-column in dogtable?
If you use a Join-column: How about just adding another join-column for the breeder's selection? Thats not the nicest solution as dogs could possibly be selected by other breeders than their own, but it's an easy solution.
Here are sample mappings for this example. I end up with four tables: dogs, breeders, breederDogs, and breederSelectedDogs:
Code:
<class name="Dog" table="dogs">
<cache usage="read-write"/>
<id name="id" column="id">
<generator class="identity"/>
</id>
<property name="name" length="40"/>
<many-to-one name="breeder" abstract="true" not-null="true" cascade="none" />
</class>
Code:
<class name="Breeder" table="breeders">
<cache usage="read-write"/>
<id name="id" column="id">
<generator class="identity"/>
</id>
<property name="first" length="25"/>
<property name="middle" length="25"/>
<property name="last" length="50"/>
<property name="username" length="50"/>
<property name="password" length="50"/>
<list name="selectedDogs" table="breederSelectedDogs" cascade="all,delete-orphan">
<key column="person" />
<list-index column="idx" />
<many-to-many class="Dog" column="dog" />
</list>
<list name="dogs" table="breederDogs" cascade="all,delete-orphan">
<key column="breeder" />
<list-index column="idx" />
<many-to-many class="Dog" column="dog" />
</list>
</class>
I'm unclear on what you are suggesting I do. Would you be able to clarify further?
I guess the issue for me with adding a DogSelection entity is that I don't need it in my pure java logic. Or with adding another property to Dog or Breeder. I have two sets in my Breeder and I can get everything I need. So it seems like there should be a way to do it with Hibernate that I'm just not aware of.
Thanks for your help!