Home » Modeling » EMF » [Teneo] On delete child, parent id is set to null before actual delete statement
[Teneo] On delete child, parent id is set to null before actual delete statement [message #1063125] |
Wed, 12 June 2013 12:10 |
Ricky de Klerck Messages: 295 Registered: January 2011 |
Senior Member |
|
|
Hi,
I'm struggling with this all day, so hope I hope someone can help me..
This is my (simplified) model:
- Parent
-- childs : Child 0..* (containment:true (cascade ALL), opposite:parent)
- Child
-- parent : Parent 1 (teneo.jpa: @JoinColumn(name="PARENT_ID") )
When I delete a Child from 'childs' it tries to set 'parent' to NULL, but it has a NOT NULL constraint in the DB so it raises an error. After this update, the delete statement is called.
How can I change the behaviour so the delete statement is called right away?
I read something about setting inverse but I don't know where and how to set this. I have no teneo.jpa on childs, because of the opposite...
Hope someone can help, thanks in advance!
[Updated on: Wed, 12 June 2013 12:11] Report message to a moderator
|
|
|
Re: [Teneo] On delete child, parent id is set to null before actual delete statement [message #1063228 is a reply to message #1063125] |
Wed, 12 June 2013 18:03 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Ricky,
You have to set a OneToMany annotation on the childs efeature with mappedBy attribute set to parent, in addition indexed
should be set to false:
@OneToMany(inverse=true, indexed=false)
This should create the inverse="true".
See these posts/links:
https://forum.hibernate.org/viewtopic.php?p=2383090
https://bugs.eclipse.org/bugs/show_bug.cgi?id=242479
gr. Martin
On 06/12/2013 02:10 PM, Ricky de Klerck wrote:
> Hi,
>
> I'm struggling with this all day, so hope I hope someone can help me..
>
> This is my (simplified) model:
>
> - Parent
> -- childs : Child 0..* (containment:true (cascade ALL), opposite:parent)
> - Child
> -- parent : Parent 1 (teneo.jpa: @JoinColumn(name="PARENT_ID")
>
> When I delete a Child from 'childs' it tries to set 'parent' to NULL, but it has a NOT NULL constraint in the DB so it
> raises an error. After this update, the delete statement is called.
>
> How can I change the behaviour so the delete statement is called right away?
>
> I read something about setting inverse but I don't know where and how to set this. I have no teneo.jpa on childs,
> because of the opposite...
>
> Hope someone can help, thanks in advance!
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
| | | | | | | |
Re: [Teneo] On delete child, parent id is set to null before actual delete statement [message #1064280 is a reply to message #1064263] |
Tue, 18 June 2013 14:16 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Ricky,
I think the best solution is to create a new instance for the root and copy the content over to that new root and save it.
gr. Martin
On 06/18/2013 03:38 PM, Ricky de Klerck wrote:
> You're right, I removed the opposite but everything works when I turned it back on.
>
> I have still one question though.. In our structure we define folders and subfolders. A folder is a root (no parent) or
> subfolder. When I want to make a folder root, I simply set the parent to null and save. But, because of the cascade, the
> folder is actually deleted from the database! How can I prevent this?
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Sat Oct 19 19:44:34 GMT 2024
Powered by FUDForum. Page generated in 0.04124 seconds
|