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: OneToMany and ManyToOne duplicated entries problem
PostPosted: Tue Jan 16, 2007 7:00 pm 
Newbie

Joined: Fri Aug 04, 2006 3:45 pm
Posts: 4
Location: Chile
Hibernate version:3.2

Mapping documents:Annotations

Code between sessionFactory.openSession() and session.close(): Not using sessions

Name and version of the database you are using:Postgres 8.1


Hi, i have a problem with oneTomany and ManyToOne Relations. Have two clasess Process and Task. A process may have several tasks so i have the next mapping with annotations.

Process.java
Code:
@Entity
@Table(name="PRM_PROCESS")
public class Process {

...

   /**
    * Process tasks
    */
   @OneToMany(mappedBy="process", fetch=FetchType.EAGER, cascade=CascadeType.ALL)
   private List<Task> tasks = new ArrayList<Task>();
   
....

}


Task.java
Code:

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@Table(name="PRM_TASKS")
public abstract class Task {

...

   /**
    * process
    */
   @ManyToOne
   @JoinColumn(name="PROCESS_ID")
   public processmanager.Process process;


...
}


The problem is when i persist a process... and then recovered from db, it have duplicated asociated tasks. Let's say Process p has task1,task2 and task3 Tasks...so when i recover process p it has three task1,2 and 3 (same tasks)

Anyone knows where is my bug?

Thanks in advance.

Agustin Almonte


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.