Hello,
I have two tables.
Code:
________________
| USER |
|________________| _______________
| user_id | | LANGUAGE |
| name | |_______________|
| fk_language_id |<----> | language_id |
|________________| | label |
|_______________|
I want to mapping them to the single class:
Code:
public class User{
private Integer id;
private String name;
private String language;
...
}
Is it possible to do this?
Hibernate version 3.6.7.
I have no acess to DB so I can't create views.
I tried this mapping:
Code:
<hibernate-mapping package="my.example.entity">
<class name="User" table="USER" >
<id name="id" column="user_id">
<generator class="native" />
</id>
<property name="name" column="name" />
<join table="LANGUAGE" optional="true" >
<key column="language_id" foreign-key="fk_language_id" />
<property name="language" column="label" />
</join>
</class>
</hibernate-mapping>
but it generates following sql:
Code:
select
u.user_id as user1_6_,
u.name as name6_,
l.label as label7_
from
USER u left outer join LANGUAGE l on u.user_id=l.language_id