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>
</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>
</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 |