Hibernate federated Primary key combination component (component)

Source: Internet
Author: User

Package db.domain;

/**
* PersonId entity. @author MyEclipse Persistence Tools
*/

public class PersonId implements Java.io.Serializable {

Fields

Private String FirstName;
Private String LastName;

Constructors

/** default Constructor */
Public PersonId () {
}

/** Full Constructor */
Public PersonId (String firstname, string lastname) {
This.firstname = FirstName;
This.lastname = LastName;
}

Property accessors

Public String Getfirstname () {
return this.firstname;
}

public void Setfirstname (String firstname) {
This.firstname = FirstName;
}

Public String Getlastname () {
return this.lastname;
}

public void Setlastname (String lastname) {
This.lastname = LastName;
}

public boolean equals (Object other) {
if ((this = other))
return true;
if ((other = = null))
return false;
if (! ( Other instanceof PersonId))
return false;
PersonId Castother = (PersonId) Other;

Return ((this.getfirstname () = = Castother.getfirstname ()) | | (This
. getfirstname ()! = NULL
&& castother.getfirstname ()! = null && this.getfirstname ()
. Equals (Castother.getfirstname ())))
&& ((this.getlastname () = = Castother.getlastname ()) | | (This
. getlastname ()! = NULL
&& castother.getlastname ()! = NULL && this
. Getlastname (). Equals (Castother.getlastname ()));
}

public int hashcode () {
int result = 17;

result = PNS * result
+ (getfirstname () = = null? 0:this.getfirstname (). Hashcode ());
result = PNS * result
+ (getlastname () = = null? 0:this.getlastname (). Hashcode ());
return result;
}

}

Package db.domain;

/**
* Person entity. @author MyEclipse Persistence Tools
*/

public class Person implements Java.io.Serializable {

Fields

Private PersonId ID;
Private String sex;
Private Integer age;
Private String birth;

Constructors

/** default Constructor */
Public person () {
}

/** Minimal Constructor * *
Public person (PersonId ID) {
This.id = ID;
}

/** Full Constructor */
Public person (PersonId ID, string sex, Integer age, string birth) {
This.id = ID;
This.sex = sex;
This.age = age;
This.birth = birth;
}

Property accessors

Public PersonId getId () {
return this.id;
}

public void SetId (PersonId id) {
This.id = ID;
}

Public String Getsex () {
return this.sex;
}

public void Setsex (String sex) {
This.sex = sex;
}

Public Integer Getage () {
return this.age;
}

public void Setage (Integer age) {
This.age = age;
}

Public String Getbirth () {
return This.birth;
}

public void Setbirth (String birth) {
This.birth = birth;
}

}

<component name= "Address" class= "Address" >
<property name= "PostalCode" type= "string" >
<column name= "PostalCode" length= "/>"
</property>
<property name= "mobile" type= "string" >
<column name= "mobile" length= "/>"
</property>
</component>

Hibernate federated Primary Key composition component (component)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.