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.  [ 1 post ] 
Author Message
 Post subject: Problems with data selection.
PostPosted: Tue Dec 09, 2008 7:47 am 
Newbie

Joined: Tue Dec 09, 2008 7:36 am
Posts: 1
Hibernate version:2.1

Hi, all!

I have got a problem:

There are 3 entities: Account, Card, Person. Account related to the card within ISS_REF_TAB table, Card related to the Person within the same table.

Code:
@Entity
@PersistenceUnit(unitName="smartbo")
@Table(name = "ISS_ACCT_TAB")
public class AccountBO implements Serializable
{
   private static final long serialVersionUID = 1771063352348052795L;

   public AccountBO()
    {
        super();
    }

   @Id
   @Column(name="ACCT_NUM")
   private String accountNum;

   @ManyToMany(fetch = FetchType.EAGER)
   @JoinTable(
                name = "ISS_REF_TAB",
                joinColumns = {@JoinColumn(name = "ISS_ACCT_NUM", referencedColumnName = "ACCT_NUM")},
                inverseJoinColumns = {@JoinColumn(name = "ISS_CARD_NUM", referencedColumnName = "CARD_NUM")}
             )
       private List<CardBO> cards = new ArrayList<CardBO>();

   public String getAccountNum() {
      return accountNum;
   }

   public void setAccountNum(String accountNum) {
      this.accountNum = accountNum;
   }

   public List<CardBO> getCards() {
      return cards;
   }

   public void setCards(List<CardBO> cards) {
      this.cards = cards;
   }
}


@Entity
@PersistenceUnit(unitName="smartbo")
@Table(name = "ISS_CARD_TAB")
public class CardBO implements Serializable
{
   private static final long serialVersionUID = 7411289056455489513L;


    public CardBO()
    {
        super();
    }

   @Id
   @Column(name="CARD_NUM")
   private String cardNumber;
   
   @ManyToOne(fetch = FetchType.EAGER)
   @JoinTable(
                name = "ISS_REF_TAB",
                joinColumns = {@JoinColumn(name = "ISS_CARD_NUM", referencedColumnName = "CARD_NUM")},
                inverseJoinColumns = {@JoinColumn(name = "ISS_PERSON_ID", referencedColumnName = "PERSON_ID")}
             )
       private PersonBO person = new PersonBO();

   public String getCardNumber() {
      return cardNumber;
   }

   public void setCardNumber(String cardNumber) {
      this.cardNumber = cardNumber;
   }

   public PersonBO getPerson() {
      return person;
   }

   public void setPerson(PersonBO person) {
      this.person = person;
   }
}


@Entity
@PersistenceUnit(unitName="smartbo")
@Table(name = "PERSON_TAB")
public class PersonBO implements Serializable
{

   private static final long serialVersionUID = -3065605114940266756L;

   public PersonBO()
    {
        super();
    }

   @Id
   @Column(name="PERSON_ID")
   private String personId;

   public String getPersonId() {
      return personId;
   }

   public void setPersonId(String personId) {
      this.personId = personId;
   }
}



I try to execute next query:

Code:
Query qry = _emBO.createQuery("SELECT " +
         "f.cards " +
         "FROM " +
            "AccountBO f " +
         "WHERE " +
         "f.accountNum = ?");

   cardsBO = qry.getResultList();



As a result i have list of cards with right id's, but for the every card in list, property "person" is null. Can anybody tell me where is my mistake?


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

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.