DanielSap wrote:
I can give a concrete situation that illustrate the problem.
It's not about eclipse tools, it's more likely about writing a hibernate mapping file!
I have a table PAYMENT and another table PAYMENT_STATUS
In table payment I have a foreign key PAYMENT_STATUS_ID.
I have only one class Payment. And I use HQL and hibernate mapping file
to map all the fields from the PAYMENT table to the Payment class.
...("from Payment");
It maps all the table fields to the class Person
And it works fine, but!
But I can't show the user the PAYMENT_STATUS_ID field. This is an Integer field ant does not make any sanse to the user. But I have only this property in Payment. I want to show the user the name of the Status.
This status is in the second table - PAYMENT_STATUS.NAME.
I tought that the simplest solution will be to write one more property in the hibernate mapping file (Payment.hbm.xml). And in this property tag to say that this is a column from another table, and the foreign key is ...!
And it should look something like that
<property name="statusText" table="PAYMENT_STATUS" key="STATUS_ID" column="STATUS_TEXT" />
and this will cause a join between these 2 tables on the field STATUS_ID
and return of the STATUS_TEXT column
I don't want to have extra class for my second table.
Also I don't want to use formula in my property tag
Tanks for the reply, wild_oscar!
Best, Daniel
I believe this is what you're looking for:
http://www.thearcmind.com/confluence/display/RandomThoughts/Hibernate+need+to+access+properties+on+join+table
I don't think it's recommended, though, as I suspect you'll get into problems if you update the values from your STATUS_TEXT column...
Tell us if it works.
PS: If you feel my answer was useful, please rate the answer. Thanks![/url]