Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-3434 - hql insert doesn't work when inserting into a table with c…
…omposite-id
- Loading branch information
Showing
4 changed files
with
114 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
hibernate-testsuite/src/test/java/org/hibernate/test/hql/CompositeIdEntity.hbm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE hibernate-mapping SYSTEM "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" > | ||
|
||
<hibernate-mapping package="org.hibernate.test.hql"> | ||
|
||
<class name="CompositeIdEntity"> | ||
<composite-id> | ||
<key-property name="key1" /> | ||
<key-property name="key2" /> | ||
</composite-id> | ||
|
||
<property name="someProperty" /> | ||
</class> | ||
|
||
</hibernate-mapping> |
60 changes: 60 additions & 0 deletions
60
hibernate-testsuite/src/test/java/org/hibernate/test/hql/CompositeIdEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.hibernate.test.hql; | ||
|
||
import java.io.Serializable; | ||
|
||
public class CompositeIdEntity implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private Long key1; | ||
private String key2; | ||
private String someProperty; | ||
|
||
public Long getKey1() { | ||
return key1; | ||
} | ||
|
||
public void setKey1( Long key1 ) { | ||
this.key1 = key1; | ||
} | ||
|
||
public String getKey2() { | ||
return key2; | ||
} | ||
|
||
public void setKey2( String key2 ) { | ||
this.key2 = key2; | ||
} | ||
|
||
public String getSomeProperty() { | ||
return someProperty; | ||
} | ||
|
||
public void setSomeProperty( String someProperty ) { | ||
this.someProperty = someProperty; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
// not really needed, thus the dumb implementation. | ||
return 42; | ||
} | ||
|
||
@Override | ||
public boolean equals( Object obj ) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if ( !( obj instanceof CompositeIdEntity ) ) { | ||
return false; | ||
} | ||
CompositeIdEntity other = ( CompositeIdEntity ) obj; | ||
if ( key1 == null ? other.key1 != null : !key1.equals( other.key1 ) ) { | ||
return false; | ||
} | ||
if ( key2 == null ? other.key2 != null : !key2.equals( other.key2 ) ) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |