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. Advertisements

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,990
    Ilias Lazaridis
    Dec 27, 2004
  2. Replies:
    0
    Views:
    4,153
  3. news.frontiernet.net
    Replies:
    6
    Views:
    1,432
    news.frontiernet.net
    Apr 16, 2004
  4. RC
    Replies:
    0
    Views:
    548
  5. RC
    Replies:
    0
    Views:
    926
  6. Eleanna Skouta
    Replies:
    2
    Views:
    9,214
    Arne Vajhøj
    Dec 9, 2008
  7. snehasish
    Replies:
    0
    Views:
    1,756
    snehasish
    Oct 27, 2009
  8. Renie83
    Replies:
    1
    Views:
    284
    Kiran Math
    Jul 10, 2003
Loading...