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.javaCode:
@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