-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Trouble annotatin a class to grab a String out of a lookup t
PostPosted: Mon Apr 06, 2009 6:44 pm 
Newbie

Joined: Mon Apr 06, 2009 6:24 pm
Posts: 1
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.