How do you just map a lookup table's varchar into an object *instead of* the foreign key to that lookup table?
Hibernate version: 3.2.5
Name and version of the database you are using: MySQL 5.2
The generated SQL (show_sql=true):
Code:
select rt.report_data_id as report3_1_,
rt.id as id1_,
lt.tip_ext_id as tip1_30_0_
from report_tip rt
left outer join
lu_tip lt on rt.id=lt.id <--- here's the problem
where rt.report_data_id=?
order by rt.sequence_num asc
I have 2 tables that I want to map in to a single class.
I have the "report_tip" table with a schema like:
Code:
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| tip_id | int(10) unsigned | YES | MUL | NULL | |
And I have a lookup tip table ("lu_tip") with a schema like this:
Code:
| Field | Type | Null | Key | Default | Extra |
+------------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| tip_ext_id | varchar(100) | YES | UNI | NULL | |
+------------+------------------+------+-----+---------+----------------+
What I want to do is map the varchar lu_tip.tip_ext_id directly into the ReportTip's getTipId String, like this:
Code:
@Entity
@Table(name="report_tip")
@SecondaryTable(name="lu_tip")
public class ReportTip extends AbstractEntity {
private ReportData reportData;
private String tipId;
... snip ...
@JoinTable(name = "lu_tip",
joinColumns = @JoinColumn(name="tip_id"),
inverseJoinColumns = @JoinColumn(name="id")
)
@Column(name = "tip_ext_id", table="lu_tip")
public String getTipId() {
return tipId;
}
The ReportTip's tipId gets mapped as null, in part (because?) of the SQL that gets generated (shown above).
Thanks a ton in advance!