-->
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: many-to-many with a sequence generated index column
PostPosted: Thu Oct 30, 2003 2:11 pm 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
We have a many-to-many with a sequence generated index column. Is there any way to use this relationship without creating a mapping file for it? Thanks.

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2003 2:46 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 7:53 pm
Posts: 66
Location: Lakeland, Florida USA
See this tread -
http://forum.hibernate.org/viewtopic.ph ... d1201843ff
Only difference is your table that resolves the many-to-many has a synthetic key (good work, DBA) instead of a composit key. Right?

Jeff


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2003 4:38 pm 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
Thats doesn't quite solve our problem, here is some more detailed information, from the user:

Match.hbm.xml

<set name="invoices" cascade="all" table="INVOICE_MATCH" lazy="true" >
<key column="MATCH_ID"/>
<many-to-many class="com.notiva.core.data.invoice.AbstractInvoice" column="INVOICE_ID"/>
</set>

InvoiceMatch.hbm.xml

<hibernate-mapping>
<class name="com.notiva.core.data.match.InvoiceMatch" table="INVOICE_MATCH">
<id column="INVOICE_MATCH_ID" name="id" type="java.lang.Long" unsaved-value="null">
<generator class="com.notiva.util.hibernate.SequenceIntervalGenerator">
<param name="sequence">SEQ_INVOICE_MATCH_ID</param>
<param name="interval">1</param>
</generator>
</id>
<property column="INVOICE_ID" length="10" name="invoice" not-null="false" type="com.notiva.core.data.invoice.AbstractInvoice"/>
<property column="MATCH_ID" length="10" name="match" not-null="true" type="com.notiva.core.data.match.Match"/>
</class>
</hibernate-mapping>

match.getInvoices() is returning set of invoices.

but, when try to save match like this

Match match = new Match();
match.setInvoices(invoices); // invoices are set of com.notiva.core.data.invoice.AbstractInvoice objects.

Session session = HibernateContext.getReadWrite().getSession();
session.save(match);

error:

Hibernate: insert into INVOICE_MATCH (MATCH_ID, INVOICE_ID) values (?, ?)

(util.JDBCExceptionReporter 36 ) SQL Error: 1400, SQLState: 23000
(util.JDBCExceptionReporter 44 ) ORA-01400: cannot insert NULL into ("INVOICE_MATCH"."INVOICE_MATCH_ID")

It's not generating the key for some reason, any ideas?

Matt


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.