Get data from two table into one java class with hibernate

H

hazan

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top