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