You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by mlounnaci <ml...@hb-technologies.dz> on 2010/02/08 14:39:15 UTC

entity update


Hello friends

I have an entity called workflow and another one called process.
The workflow has a collection of processes, it means a oneToMany relation,
and the process itself has a reference to workflow.
@Entity
public class Workflow implements Serializable{
	private static final long serialVersionUID = -6940501155081900165L;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY) 
	protected int id;
	@Column(name = "NAME")
	protected String name;
	
	@OneToMany(mappedBy="workflow",cascade = {CascadeType.PERSIST,
CascadeType.MERGE, CascadeType.REMOVE}, fetch=FetchType.EAGER)
	protected List<Process> processes;
	public List<Process> getProcesses() {
		return processes;
	}
    
	public void setProcesses(List<Process> processes) {
		this.processes = processes;
	}

}

@Entity
public class Process implements Serializable{

	@ManyToOne(cascade = CascadeType.ALL)
	Workflow workflow;

        Other fields.........
}


The problem is how can I delete a process from a workflow assuming that the
workflow entity was already persisted in database.

Thanks in advence.
mlounnaci
-- 
View this message in context: http://n2.nabble.com/entity-update-tp4534156p4534156.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: entity update

Posted by Rick Curtis <cu...@gmail.com>.
Have you looked at the EntityManager interface [1]?

[1]
http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#remove%28java.lang.Object%29

-- 
Thanks,
Rick

On Mon, Feb 8, 2010 at 7:39 AM, mlounnaci <ml...@hb-technologies.dz>wrote:

>
>
> Hello friends
>
> I have an entity called workflow and another one called process.
> The workflow has a collection of processes, it means a oneToMany relation,
> and the process itself has a reference to workflow.
> @Entity
> public class Workflow implements Serializable{
>        private static final long serialVersionUID = -6940501155081900165L;
>        @Id
>        @GeneratedValue(strategy=GenerationType.IDENTITY)
>        protected int id;
>        @Column(name = "NAME")
>        protected String name;
>
>        @OneToMany(mappedBy="workflow",cascade = {CascadeType.PERSIST,
> CascadeType.MERGE, CascadeType.REMOVE}, fetch=FetchType.EAGER)
>        protected List<Process> processes;
>        public List<Process> getProcesses() {
>                return processes;
>        }
>
>        public void setProcesses(List<Process> processes) {
>                this.processes = processes;
>        }
>
> }
>
> @Entity
> public class Process implements Serializable{
>
>        @ManyToOne(cascade = CascadeType.ALL)
>        Workflow workflow;
>
>        Other fields.........
> }
>
>
> The problem is how can I delete a process from a workflow assuming that the
> workflow entity was already persisted in database.
>
> Thanks in advence.
> mlounnaci
> --
> View this message in context:
> http://n2.nabble.com/entity-update-tp4534156p4534156.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>