[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1982) Merge doesnt work with composite keys
Jara Cesnek (JIRA)
noreply at atlassian.com
Fri Oct 6 09:48:24 EDT 2006
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1982?page=comments#action_24742 ]
Jara Cesnek commented on HHH-1982:
----------------------------------
Fixed in Hibernate Core 3.2.cr4.
Now working as expected.
> 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
>
>
> 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.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list