-->
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.  [ 3 posts ] 
Author Message
 Post subject: How 'SchemaExport' generates separate relationship tables?
PostPosted: Mon Jan 15, 2007 7:40 am 
Newbie

Joined: Sun Feb 05, 2006 7:46 pm
Posts: 18
I've been caught in a bind for last two days. Please help...

From the code below 'SchemaExport' automatically generates a table, "AccountRecords_Record", and three fields, "AccountRecords_id", "creditRecordList_hbm_id", and "debitRecordList_hbm_id" on that table.

This is fine... but...

Whenever I tried to make an 'AccountRecords' object persistent, I get an error message, "NULL value was tried to be inserted to the column, 'debitRecordList_hbm_id' on the table, 'AccountRecords_Record'.

Code:
@Entity
public class AccountRecords {
    private Long id;
    private List<Record> creditRecordList = new ArrayList<Record>();
    private List<Record> debitRecordList = new ArrayList<Record>();
   
    @OneToMany(cascade = CascadeType.ALL, targetEntity=Record.class)
    public List<Record> getCreaditRecordList() {
        return creditRecordList;
    }
    @OneToMany(cascade = CascadeType.ALL, targetEntity=Record.class)
    public List<Record> getDebitRecordList() {
        return debitRecordList;
    }
    // .....
}


It seems this is caused by having two "OneToMany" relationships i.e. creditRecordList_hbm_id and debitRecordList_hbm_id on the same table. Which annotation allows me to separate them? Or, is there any other solution to this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 21, 2007 7:20 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@JoinTable(name="....")

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 1:55 am 
Newbie

Joined: Sun Feb 05, 2006 7:46 pm
Posts: 18
Gee.. it works :-) Thank you very much for your help.


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

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.