-->
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.  [ 4 posts ] 
Author Message
 Post subject: Question about modeling with hibernate
PostPosted: Thu May 03, 2007 11:01 am 
Newbie

Joined: Tue Mar 06, 2007 9:09 am
Posts: 10
Hi guru I have 2 table

Emp table wit the following field:
    -empno,
    -Ename
    -jobId

and a second table JobDescr containing the following fields:
-jobId
-JobDescription.

The key of emp is empno and the key of JobDescr is jobId.
There is also a foreing key among JobId on Emp and Jobid on JobDescr

I'd like to build a class emp as follow
Code:
public class Emp java.io.Serializable {


     private BigDecimal empno;
     private String ename;
     private BigDecimal jobId;
     private String jobDescription;
     
    public Emp() {
    }

public BigDecimal getEmpno() {
        return this.empno;
    }
   
    public void setEmpno(BigDecimal empno) {
        this.empno = empno;
    }


public String getJobId() {
        return this.jobId;
    }
   
    public void setJob(String job) {
        this.jobId = job;
    }

  public String getEname() {
        return this.ename;
    }
   
    public void setEname(String ename) {
        this.ename = ename;
    }
   //Read only
   public String getJobDescription() {
        return this.jobDescription;
    }



so the query to retrieve an emp entity should be:
Code:
select ename,jobId,jobDescription
from emp, job
where emp.jobId=JobDescr.jobId



Unfortunately I'm unable how configure my hbm.
Shoud I use UserType?
any help will be appreciate.
thanks in advance
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 11:27 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
you can use regenge to generate your hbm.xml/pojo/daos, or you could write them by hand or use anotations...
what's in the log when you try and run your code?

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 2:01 pm 
Newbie

Joined: Tue Mar 06, 2007 9:09 am
Posts: 10
adamgibbons wrote:
you can use regenge to generate your hbm.xml/pojo/daos, or you could write them by hand or use anotations...
what's in the log when you try and run your code?

the proble is how build hbm. In fact I'd like in the same class attributes from 2 different table (JOb description from job table all other from emP)
If i use reveng this will generate an association. I dont' know how model this use case


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 6:03 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
That's not how hibernate works. you get one hbm, pojo and dao per table. If you want to make an object that has a few feilds from differnt tables then do a hql select into a custom vo.

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


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

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.