-->
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.  [ 4 posts ] 
Author Message
 Post subject: Embedded/Components not cascading a manyToOne relation
PostPosted: Wed Feb 13, 2008 7:11 am 
Beginner
Beginner

Joined: Fri Oct 06, 2006 2:49 am
Posts: 25
Hi all,

I have a problem of cascading a relation many-to-one in a component. Syntactically, here is my classes:

Code:

public class Parent {
    @CollectionOfElements(fetch = FetchType.LAZY)
    @JoinTable(name = "parent_child"))
    @IndexColumn(name = "position", base = 0)
    private List<Child> children = new ArrayList<Child>();

     ....
}

@Embeddable
public class Child {
     
    @ManyToOne(fetch=FetchType.EAGER)
    @NotNull
    private Element element;

    ...
}

public class Element {....}




When I try to persist a parent containing children which have all an element, I am expecting it will persist everything by cascading. In fact it returns me an exception TransientObjectException on the object element. The child cannot be persisted because it is linked to a transient entity (element of class Element) which is not persisted automatically => no cascade is happening on child.element :(

I am wondering if this is a limitation of the components or if this is a bug.

Thanks already for who might help :)

Tiggy


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 13, 2008 3:03 pm 
Beginner
Beginner

Joined: Fri Jan 26, 2007 3:16 pm
Posts: 24
Did you find a resolution to this, b/c I am having a very similar problem -- see http://forum.hibernate.org/viewtopic.php?t=983780


Top
 Profile  
 
 Post subject: Re: Embedded/Components not cascading a manyToOne relation
PostPosted: Wed Feb 13, 2008 6:07 pm 
Beginner
Beginner

Joined: Fri Oct 06, 2006 2:49 am
Posts: 25
I am sorry for those who read this post. I forgot to mention something very important: there is of course a cascade on Child.element (that is why i do not understand the behavior of Hibernate).

The correction is done under in my original post

tiggy wrote:
Hi all,

I have a problem of cascading a relation many-to-one in a component. Syntactically, here is my classes:

Code:

public class Parent {
    @CollectionOfElements(fetch = FetchType.LAZY)
    @JoinTable(name = "parent_child"))
    @IndexColumn(name = "position", base = 0)
    private List<Child> children = new ArrayList<Child>();

     ....
}

@Embeddable
public class Child {
     
    @ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.ALL)
    @NotNull
    private Element element;

    ...
}

public class Element {....}




When I try to persist a parent containing children which have all an element, I am expecting it will persist everything by cascading. In fact it returns me an exception TransientObjectException on the object element. The child cannot be persisted because it is linked to a transient entity (element of class Element) which is not persisted automatically => no cascade is happening on child.element :(

I am wondering if this is a limitation of the components or if this is a bug.

Thanks already for who might help :)

Tiggy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 11:58 am 
Newbie

Joined: Fri Mar 28, 2008 9:08 am
Posts: 3
Related posts:
http://forum.hibernate.org/viewtopic.php?t=976534
http://forum.hibernate.org/viewtopic.php?t=983780


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

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.