Markus Döring (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-9513 (
https://hibernate.atlassian.net/browse/HHH-9513?atlOrigin=eyJpIjoiNWIwOWY...
)
Re: Cascading inserts are failing after upgrade (
https://hibernate.atlassian.net/browse/HHH-9513?atlOrigin=eyJpIjoiNWIwOWY...
)
I had the same problem (with 4.1.11 and 5.1) and found that this is only occuring when
using hbm.xml files.
I changed some of my entites to annotations and the problem is solved.
Parts of my hbm.xml file causing the problem:
<hibernate-mapping package = "de.srs.pen.dao.base" default -access=
"property" default -cascade= "none" default -lazy= " true "
>
< class name= "FormValue" table= "form_values" >
<id name= "valueKey" type= "java.lang. Long " >
<column name= "value_key" />
<generator class= " native " />
</id>
<map name= "details" inverse= " true " cascade=
"all" >
<key>
<column name= "value_key" not- null = " true "
/>
</key>
<map-key type= "java.lang. Long " column= "detail_key"
/>
<one-to-many class= "FormValueDetail" />
</map>
</ class& gt;
</hibernate-mapping>
<hibernate-mapping package = "de.srs.pen.dao.base" default -access=
"property" default -cascade= "none" default -lazy= " true "
>
< class name= "FormValueDetail" table= "form_value_details"
>
<id name= "detailKey" type= "java.lang. Long " >
<column name= "detail_key" />
<generator class= " native " />
</id>
<many-to-one name= "value" class= "FormValue" fetch=
"join" lazy= " false " foreign-key= "FK_018_value" >
<column name= "value_key" not- null = " true " />
</many-to-one>
</ class& gt;
</hibernate-mapping>
Annotated telations with problem solved:
@Entity
public class FormValue {
@Id
@Column(name = "value_key" )
@GeneratedValue(strategy = GenerationType.AUTO)
private Long valueKey;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "value" )
@MapKey(name = "detailKey" )
private Map< Long , FormValueDetail> details = new HashMap< Long ,
FormValueDetail>(0);
}
@Entity
public class FormValueDetail
{ @Id @Column(name = "detail_key") @GeneratedValue(strategy =
GenerationType.AUTO) private Long detailKey; @ManyToOne @JoinColumn(name =
"value_key") @ForeignKey(name = "FK_018_value") private FormValue
value; }
Maybe this helps finding the issue or someone else finding a workaround.
Regards
Markus Döring
(
https://hibernate.atlassian.net/browse/HHH-9513#add-comment?atlOrigin=eyJ...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-9513#add-comment?atlOrigin=eyJ...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100125- sha1:63ccdc5 )