Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Get data from two table into one java class with hibernate

Reply
Thread Tools

Get data from two table into one java class with hibernate

 
 
hazan
Guest
Posts: n/a
 
      01-14-2007

Hi,

I have a question in Hibernate:

I have two tables:

A: id, name
B: id, status, fk_id (fk_id is foreign key to table A)

I have java class (called javaClass) which represents table B and one
column of table A:
Id (from B), status, fk_id, name (from A).

The mappings file of table B map all columns of table B to the right
property in javaClass (without mapping column name of table A).

I want to get list of object of type javaClass.

I tried: session.createSQLQuery ( "select B.*, A.name from A, B
where A.id = B.fk_id)

The problem is, how do I map column "name" from table A to member
"name" in the javaClass ?

Thanks,

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hibernate LazyInitializationException in web application Struts asMVC, Spring as IOC and Hibernate as ORM layer Amit Jain Java 7 04-27-2009 10:27 AM
HIBERNATE - java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration Eleanna Skouta Java 2 12-09-2008 02:09 AM
Hibernate cannot find hibernate.cfg.xml jstorta Java 1 01-19-2008 01:45 PM
Hibernate Syncronizer now generates code for Hibernate 3.0 msenin@covad.net Java 0 07-14-2005 05:47 AM
[HIBERNATE] [EVALUATION] - Gavin King Censors Hibernate Forum Ilias Lazaridis Java 0 12-27-2004 04:26 AM



Advertisments