package demo35;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import org.openswing.swing.message.receive.java.ValueObjectImpl;
/**
*
* @author carniel
*/
@Entity
public class Person extends ValueObjectImpl implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="PersonID")
private Long id;
private String surname;
private String name;
@OneToOne(cascade=CascadeType.ALL)
private Address address;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Person)) {
return false;
}
Person other = (Person) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
public String toString() {
return surname + ", " +
name + ": " +
address.getStreet() + ", " +
address.getCity() + ", " +
address.getCountry();
}
public
String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
}