-->
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.  [ 1 post ] 
Author Message
 Post subject: @OneToMany and Cascade.All not working
PostPosted: Wed Dec 17, 2008 5:31 pm 
Newbie

Joined: Thu Mar 08, 2007 5:14 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.3.1

Mapping documents:
On class:
Code:
@Entity
@Table(name = "LOCATION")
@AttributeOverride(name = "id", column =
   @Column(name = "LOCATION_ID",
         nullable = false,
         unique = true))
@Proxy(proxyClass = ILocation.class, lazy = true)

On field:
Code:
@OneToMany(targetEntity = Assignment.class,
            mappedBy = "location",
            fetch = FetchType.EAGER,
            cascade = { CascadeType.ALL } )
@Cascade(org.hibernate.annotations.CascadeType.ALL)
private Collection<IAssignment> assignments;

On class:
Code:
@Entity
@Table(name = "ASSIGNMENT")
@AttributeOverride(name = "id", column =
   @Column(name = "ASSIGNMENT_ID",
         nullable = false,
         unique = true))
@Proxy(proxyClass = IAssignment.class, lazy = true)

On property (getter):
Code:
@ManyToOne(targetEntity = Location.class)
   @JoinColumn(name = "LOCATION_ID",
            nullable = false,
            unique = false,
            referencedColumnName = "LOCATION_ID")
   @ForeignKey(name = "FK_ASSIGNMENT_LOCATION")

Name and version of the database you are using: MsSQL 2005

I have bidirectional @OneToMany relation between Location and Assignments. Unfortunately cascade is not working (so assignments are not persisted together with Location...) Can anyone tell me what is wrong in given mappings? If I create getter/setter for assignments in Location class everything is working just fine - when mapping is on private field it is not working at all...

Any suggestions are welcome - thanks in advance!

Best regards,
tytus


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

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.