-->
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.  [ 2 posts ] 
Author Message
 Post subject: Association Issue
PostPosted: Thu Jul 07, 2005 12:07 pm 
Newbie

Joined: Fri Apr 22, 2005 3:21 pm
Posts: 12
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:2.1.7


Mapping documents:

/ * @hibernate.set
* cascade="all" inverse="true"
* @hibernate.collection-one-to-many
* class="java.package.OpQuestionAnswer"
* @hibernate.collection-key
* column="OPPORTUNITY_ID"
*/



Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: Oracle 9.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


I have two tables. They are in association where table A is 1:N relationship with table B. My pojo of table A has a set to hold a collection of records for Table B. The mapping is provided above.

The problem is when insert an new record in Table A, it tries to do an update on table B as opposed to doing an insert. Since both these records are new.

Similarly, for the same case if there is a recordin table A and i try to make new entry for it in table B. I add an instance of a record into the Set in the pojo of Table A. When I run an update on table A it runs an update on table B as opposed to running an insert.

Any suggestion on what I might be missing ?


Top
 Profile  
 
 Post subject: Re: Association Issue
PostPosted: Thu Jul 07, 2005 12:15 pm 
Newbie

Joined: Fri Apr 22, 2005 3:21 pm
Posts: 12
stazione_jaxrpc wrote:
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:2.1.7


Mapping documents:

/ * @hibernate.set
* cascade="all" inverse="true"
* @hibernate.collection-one-to-many
* class="java.package.OpQuestionAnswer"
* @hibernate.collection-key
* column="OPPORTUNITY_ID"
*/



Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: Oracle 9.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


I have two tables. They are in association where table A is 1:N relationship with table B. My pojo of table A has a set to hold a collection of records for Table B. The mapping is provided above.

The problem is when insert an new record in Table A, it tries to do an update on table B as opposed to doing an insert. Since both these records are new.

Similarly, for the same case if there is a recordin table A and i try to make new entry for it in table B. I add an instance of a record into the Set in the pojo of Table A. When I run an update on table A it runs an update on table B as opposed to running an insert.

Any suggestion on what I might be missing ? Another note Table B has a composite key in it. Which has ben implemented using a object which has the composite key member in it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.