Before I present my question, I just want to say that this is by far the best monitored forum I've ever seen. It's a great help to have the Hibernate Team Members so active in here! Thanks to all of you guys for all of your hard work! It's greatly appreciated!
Now, here's my question:
I'm using:
Hibernate 2.1
MySQL 3.23 (I think)
I have 2 tables consisting of the following columns:
CUS_CUSTOMER {
CUS_UID (Unique Identifer, PK)
}
CTC_CONTACT {
CTC_UID (Unique Identifier, PK),
CTC_CUS_UID (FK to CUS_CUSTOMER table)
}
Based on this setup, one contact can have mulitiple customers. When I retrieve contacts based on a given CUS identifier, I receive a list of contacts and each contact has redundant CUS information in it, with the same customer information being displayed at the end of the results again. Is there any way to just receive one CUS object at the end, without the same information inside each of the CTC objects?
I've tried looking at <one-to-many mappings in a set, but that didn't seem to solve my problem. Does anyone have any ideas?
Here is an example of my output:
Code:
<customer-with-contacts>
<ctc-list>
<ctc>
<uid>19</uid>
<id>CTC018</id>
<cus-uid>
[color=red]<uid>6</uid>
<id>CUS006</id>
<name>7-Eleven</name>
<address>8376 Alaska Ct.</address>
<state>CA</state>
<city>Grass Valley</city>
<pcd-code-home>
<code>1234567</code>
<date-created>2004-03-22T15:22:49.000-08:00</date-created>
</pcd-code-home>
<phone>3452342341</phone>
<note>Interested in our new tracking system.
Have Dave Munser set up an appointment.</note>
<usr-created-by>2</usr-created-by>
<usr-updated-by>4</usr-updated-by>[/color]
</cus-uid>
<surname>Stover</surname>
<forename>Tyler</forename>
<middlename>Shawn</middlename>
<formatted-name>Stover, Tyler</formatted-name>
<title>Mr.</title>
<gender>M</gender>
<phone>1234567890 112</phone>
<fax>1234567890</fax>
<city>Kansas City</city>
<email>tss@711.com</email>
<usr-created-by>2</usr-created-by>
<usr-updated-by>3</usr-updated-by>
</ctc>
<ctc>
<uid>20</uid>
<id>CTC019</id>
<cus-uid>
<uid>6</uid>
<id>CUS006</id>
<name>7-Eleven</name>
<address>8376 Alaska Ct.</address>
<state>CA</state>
<city>Grass Valley</city>
<pcd-code-home>
<code>1234567</code>
<date-created>2004-03-22T15:22:49.000-08:00</date-created>
</pcd-code-home>
<phone>3452342341</phone>
<note>Interested in our new tracking system.
Have Dave Munser set up an appointment.</note>
<usr-created-by>2</usr-created-by>
<usr-updated-by>4</usr-updated-by>
</cus-uid>
<surname>Ivery</surname>
<forename>Jerome</forename>
<middlename>William</middlename>
<formatted-name>Ivery, Jerome</formatted-name>
<title>Mr.</title>
<gender>M</gender>
<phone>1234567890 112</phone>
<fax>1234567890</fax>
<email>jwi@711.com</email>
<usr-created-by>2</usr-created-by>
<usr-updated-by>6</usr-updated-by>
</ctc>
<ctc>
<uid>21</uid>
<id>CTC020</id>
<cus-uid>
<uid>6</uid>
<id>CUS006</id>
<name>7-Eleven</name>
<address>8376 Alaska Ct.</address>
<state>CA</state>
<city>Grass Valley</city>
<pcd-code-home>
<code>1234567</code>
<date-created>2004-03-22T15:22:49.000-08:00</date-created>
</pcd-code-home>
<phone>3452342341</phone>
<note>Interested in our new tracking system.
Have Dave Munser set up an appointment.</note>
<usr-created-by>2</usr-created-by>
<usr-updated-by>4</usr-updated-by>
</cus-uid>
<surname>Suthers</surname>
<forename>Sally</forename>
<middlename>Annette</middlename>
<formatted-name>Suthers, Sally</formatted-name>
<title>Ms.</title>
<gender>F</gender>
<fax>1234567890</fax>
<email>sas@711.com</email>
<date-created>2037-07-04T00:00:00.000-07:00</date-created>
<usr-created-by>3</usr-created-by>
<usr-updated-by>6</usr-updated-by>
</ctc>
</ctc-list>
<cus>
<uid>6</uid>
<id>CUS006</id>
<name>7-Eleven</name>
<address>8376 Alaska Ct.</address>
<state>CA</state>
<city>Grass Valley</city>
<pcd-code-home>
<code>1234567</code>
<date-created>2004-03-22T15:22:49.000-08:00</date-created>
</pcd-code-home>
<phone>3452342341</phone>
<note>Interested in our new tracking system. Have Dave
Munser set up an appointment.</note>
<usr-created-by>2</usr-created-by>
<usr-updated-by>4</usr-updated-by>
</cus>
</customer-with-contacts>
Thanks in advance for any suggestions!