pardon the n00biness,

i think i have a need to map this object model with hibernate.
i tried to make both relationships {Project-Solution} and {Solution-Route}
bidirectional by using the following annotations, however it fails:

class Project {
    @OneToMany(targetEntity = Solution.class, mappedBy = "project", cascade
= CascadeType.ALL)
   
@org.hibernate.annotations.Cascade(value=org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
    Set<Solution> solutions;
}

class Solution {
    @OneToMany(targetEntity = Route.class, mappedBy = "solution", cascade =
CascadeType.ALL)
   
@org.hibernate.annotations.Cascade(value=org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
    Set<Route> routes;

    @ManyToOne(targetEntity = Project.class)   @JoinColumn(nullable = false)
    Project project;    
}

class Route {
    @ManyToOne(targetEntity = Solution.class)   @JoinColumn(nullable =
false)
    Solution solution;
}    


i get parent/child foreign key constraint violations, unless i remove the
mappedBy annotation attribute (equivalent to  <inverse> in xml)

Am i wrong conceptually, is there a better way to map this hierarchy, am i
too stuck in the object-oriented thinking?

Removing the mappedBy attribute fixes the problem and i would think that
navigation from Route to Solution and Solution to Project should still be
possible this way.

I would love to hear your thoughts.  Thank you.
 
-- 
View this message in context: 
http://www.nabble.com/hibernate-hierarchy-mapping-question-tf4351764s2369.html#a12399951
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to