[hibernate-issues] [JIRA] (HHH-9513) Cascading inserts are failing after upgrade

Markus Döring (JIRA) jira at hibernate.atlassian.net
Thu Apr 23 06:11:16 EDT 2020


Markus Döring ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A903be654-c179-472f-8c0c-4cb9f331e57f ) *commented* on HHH-9513 ( https://hibernate.atlassian.net/browse/HHH-9513?atlOrigin=eyJpIjoiNWIwOWY4NjY1YTcyNGY3N2EzYTY2ZjYzNWY0ODdiNTAiLCJwIjoiaiJ9 )

Re: Cascading inserts are failing after upgrade ( https://hibernate.atlassian.net/browse/HHH-9513?atlOrigin=eyJpIjoiNWIwOWY4NjY1YTcyNGY3N2EzYTY2ZjYzNWY0ODdiNTAiLCJwIjoiaiJ9 )

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=eyJpIjoiNWIwOWY4NjY1YTcyNGY3N2EzYTY2ZjYzNWY0ODdiNTAiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-9513#add-comment?atlOrigin=eyJpIjoiNWIwOWY4NjY1YTcyNGY3N2EzYTY2ZjYzNWY0ODdiNTAiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100125- sha1:63ccdc5 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200423/0bc3277c/attachment.html 


More information about the hibernate-issues mailing list