There are several approaches. First, you can use a formula column:
Code:
<hibernate-mapping>
<class name="Person" table="Person">
<id name="pid" column="pid">
<generator class="native"/>
</id>
<property name="name" column="name"/>
<property name="department_name" formula="select name from department where did=department_id"/>
</class>
</hibernate-mapping>
That should work, depending on your database. Not to question your model, but it might be worthwhile to have a Person POJO with a many-to-one mapping to a Department POJO, and, if necessary, create a view like this:
Code:
create view PersonView as
select p.pid, p.name, d.name
from person p inner join department d
on p.department_id=d.did
You could then create a POJO and mapping called PersonView and use that as needed.
- Jesse[/code]