The DELETE statement conflicted with the SAME TABLE REFERENCE constraint

2,051 views
Skip to first unread message

hamdy.a.farag

unread,
Sep 4, 2010, 8:16:12 PM9/4/10
to play-framework
Hi

I'm using SQL Server and i'm having a problem deleting a record with a
self referencing f.k

Here's my Model

@Entity
@Table(name = "Employee")
public class Employee{

....

@ManyToOne
@JoinColumn(name="managerID")
public Employee managerID;

}

Now in my db, I'm having a field managerID that's a f.k to Employee

Every time I try to delete an Employee who had the managerID field set
to a value I get this error :

The DELETE statement conflicted with the SAME TABLE REFERENCE
constraint "FK_Employee_Manager


This is the case with me whenever I try to use F.k , So any ideas how
to deal with this ?

Thanks in advance

Guillaume Bort

unread,
Sep 5, 2010, 11:56:39 AM9/5/10
to play-fr...@googlegroups.com
Yes, delete the relation before deleting the entity.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

Reply all
Reply to author
Forward
0 new messages