Get data from two table into one java class with hibernate

Discussion in 'Java' started by hazan, Jan 14, 2007.

  1. hazan

    hazan Guest

    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,
     
    hazan, Jan 14, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ilias Lazaridis
    Replies:
    0
    Views:
    1,773
    Ilias Lazaridis
    Dec 27, 2004
  2. Replies:
    0
    Views:
    3,810
  3. jstorta
    Replies:
    1
    Views:
    11,849
  4. Eleanna Skouta
    Replies:
    2
    Views:
    8,513
    Arne Vajhøj
    Dec 9, 2008
  5. Amit Jain
    Replies:
    7
    Views:
    3,394
    Amit Jain
    Apr 27, 2009
Loading...

Share This Page