[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1982?page=c...
]
Emmanuel Bernard commented on HHH-1982:
---------------------------------------
I doubt it, since there are some testcases in the unit test. But if you can build a
minimal (one entity) runnable testcase that reproduce the issue, create a new issue and
attach it. Or consider some community feedbacks in
http://forum.hibernate.org
Merge doesnt work with composite keys
-------------------------------------
Key: HHH-1982
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1982
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Reporter: Jara Cesnek
Fix For: 3.2.0.cr4
Merge() operation as defined in JSR220 works fine with our entities with simple keys.
But on tables with composite keys same doesnt works.
Hibernate always try insert into table even when should only update.
@IdClass(DOGaa_smlouva_dodatek.DOGaa_smlouva_dodatekPk.class)
@MappedSuperclass
public abstract class DOGaa_smlouva_dodatek {
@Id
protected Integer id_pripad;
@Id
protected Integer pc_smlouva_dodatek;
@Embeddable
public static class DOGaa_smlouva_dodatekPk implements Serializable {
protected Integer id_pripad;
public Integer getId_pripad() {
return id_pripad;
}
public void setId_pripad(Integer id_pripad) {
this.id_pripad = id_pripad;
}
protected Integer pc_smlouva_dodatek;
public Integer getPc_smlouva_dodatek() {
return pc_smlouva_dodatek;
}
public void setPc_smlouva_dodatek(Integer pc_smlouva_dodatek) {
this.pc_smlouva_dodatek = pc_smlouva_dodatek;
}
public boolean equals(Object other){
if ( !(other instanceof DOGaa_smlouva_dodatekPk) ) {return false;}
DOGaa_smlouva_dodatekPk castOther = (DOGaa_smlouva_dodatekPk) other;
return new EqualsBuilder()
.append(id_pripad,castOther.id_pripad)
.append(pc_smlouva_dodatek,castOther.pc_smlouva_dodatek)
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(id_pripad)
.append(pc_smlouva_dodatek)
.toHashCode();
}
}
}
Second thing is when we try delete entity through merge on composite keys:
doAttach = (DOParent)
hao.getHibernateTemplate().merge(doDetach);
hao.getHibernateTemplate().delete(doAttach);
hibernate try first insert too and then delete.
When entity has simple key this code work fine.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira