[hibernate-issues] [Hibernate-JIRA] Created: (ANN-755) Cascade operations don't take affect through a @CollectionOfElements
Chris L (JIRA)
noreply at atlassian.com
Mon Jun 23 08:02:19 EDT 2008
Cascade operations don't take affect through a @CollectionOfElements
--------------------------------------------------------------------
Key: ANN-755
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-755
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate 3.2.5
Reporter: Chris L
Consider having three classes. The first is an @Entity called a View, which has a collection of @Embeddable Column objects. Column objects have an @ManyToOne relationship to a @Entity called Filter.
The three classes have a very straightforward mapping:
@javax.persistence.Entity()
@Entity(dynamicUpdate=true)
@Table(name="PORTFOLIO_VIEW")
class View {
....
@JoinTable(name="PORTFOLIO_VIEW_COLUMN",joinColumns={@JoinColumn(name="VIEW_ID")})
@IndexColumn(name="COLUMN_INDEX")
@Cascade(CascadeType.ALL)
@LazyCollection(LazyCollectionOption.FALSE)
@CollectionOfElements
private List<Column> columns;
....
}
@Embeddable
class Column {
....
@ManyToOne(fetch=FetchType.EAGER)
@Cascade(CascadeType.ALL)
@JoinColumn(name="FILTER")
@Target(FilterImpl.class)
private Filter filter;
....
}
@javax.persistence.Entity
@Entity(dynamicUpdate=true)
@Table(name="FILTER")
@DiscriminatorColumn(name="CLASS_NAME",length=255)
abstract class FilterImpl {
....
}
When I create a new view, with a new column and filter object, I should be able to save the view and have the @Cascade settings on the @CollectionOfElements and the @ManyToOne inside of Column take affect, and save the Filter. Instead, I get a TransientObjectException because the Filter hasn't been saved yet.
I know I could work around this by either making Column an Entity, or by adding code to save the Filter before saving the View. But it seems to me this is reasonable usage of an Embeddable.
This issue was originally part of a forum post http://forum.hibernate.org/viewtopic.php?t=987977
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list