java 代码
- <hibernate-mapping>
- <class name="com.pilotek.ups.pk.hbm.Table1" table="TABLE1" schema="dbo" catalog="UpsMonitor">
- <composite-id name="id" class="com.pilotek.ups.pk.hbm.Table1Id">
- <key-property name="id" type="java.lang.String">
- <column name="id" length="50" />
- </key-property>
- <key-property name="name" type="java.lang.String">
- <column name="name" length="10" />
- </key-property>
- </composite-id>
- </class>
- </hibernate-mapping>
- pojo
- public class Table1 implements java.io.Serializable {
- // Fields
- private Table1Id id;
- // Constructors
- /** default constructor */
- public Table1() {
- }
- // Property accessors
- public Table1Id getId() {
- return this.id;
- }
- public void setId(Table1Id id) {
- this.id = id;
- }
- }
- public class Table1Id implements java.io.Serializable {
- // Fields
- private String id;
- private String name;
- // Constructors
- /** default constructor */
- public Table1Id() {
- }
- /** minimal constructor */
- public Table1Id(String id) {
- this.id = id;
- }
- /** full constructor */
- public Table1Id(String id, String name) {
- this.id = id;
- this.name = name;
- }
- // Property accessors
- public String getId() {
- return this.id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public boolean equals(Object other) {
- if ( (this == other ) ) return true;
- if ( (other == null ) ) return false;
- if ( !(other instanceof Table1Id) ) return false;
- Table1Id castOther = ( Table1Id ) other;
- return ( (this.getId()==castOther.getId()) || ( this.getId()!=null && castOther.getId()!=null && this.getId().equals(castOther.getId()) ) )
- && ( (this.getName()==castOther.getName()) || ( this.getName()!=null && castOther.getName()!=null && this.getName().equals(castOther.getName()) ) );
- }
- public int hashCode() {
- int result = 17;
- result = 37 * result + ( getId() == null ? 0 : this.getId().hashCode() );
- result = 37 * result + ( getName() == null ? 0 : this.getName().hashCode() );
- return result;
- }
- }