<b>EmailAddressHibernateVO.java:</b>
Code:
package com.aviall.edi.jedi.persistence.commons.vo.hibernate;
import java.util.Date;
import javax.persistence.*;
import com.aviall.commons.vo.model.api.IEmailAddressVO;
import com.aviall.edi.jedi.persistence.commons.models.BasePersistableModel;
@Embeddable
public class EmailAddressHibernateVO extends BasePersistableModel implements IEmailAddressVO {
private static final long serialVersionUID = 1L;
@Column(length=50, nullable=false)
private String emailAddress;
@Column(length=100, nullable=false)
private String emailType;
@SuppressWarnings("unused")
private EmailAddressHibernateVO() {
super();
// TODO Auto-generated constructor stub
}
public EmailAddressHibernateVO(String emailAddress, String emailType, String createdBy, Date createdDate,
String updatedBy, Date updatedDate) {
super(createdBy, createdDate, updatedBy, updatedDate);
this.emailAddress = emailAddress;
this.emailType = emailType;
}
@Override
public String getEmailAddress() {
return emailAddress;
}
@Override
public String getEmailType() {
return emailType;
}
}
<b>PersonHibernateVO.java:</b>
Code:
package com.aviall.edi.jedi.persistence.commons.vo.hibernate;
import static javax.persistence.GenerationType.SEQUENCE;
import java.util.Date;
import java.util.Set;
import javax.persistence.*;
import com.aviall.commons.vo.model.api.IEmailAddressVO;
import com.aviall.commons.vo.model.api.IPersonVO;
import com.aviall.edi.jedi.persistence.commons.models.BaseEntityModel;
@javax.persistence.Entity
@AttributeOverride(name = "id", column = @Column(name = "PERSON_ID", nullable = false))
@Table(name = "Person")
@NamedQueries( {
@NamedQuery(name = "Person.findByFirstName", query = "select p from Person p where p.firstName = ?"),
@NamedQuery(name = "Person.findByLastName", query = "select p from Person p where p.lastName = ?") })
public class PersonHibernateVO extends BaseEntityModel implements IPersonVO {
private static final long serialVersionUID = 1L;
@Column(name = "FIRST_NAME", nullable = false, length = 100)
private String firstName;
@Column(name = "MIDDLE_NAME", nullable = false, length = 100)
private String middleName;
@Column(name = "LAST_NAME", nullable = false, length = 100)
private String lastName;
@org.hibernate.annotations.CollectionOfElements(
targetElement = com.aviall.commons.vo.model.api.IEmailAddressVO.class
)
@JoinTable(name = "PERSON_EMAIL_ADDRESS", joinColumns = @JoinColumn(name = "PERSON_ID"))
private Set<IEmailAddressVO> emailAddresses;
@SuppressWarnings("unused")
private PersonHibernateVO(){}
public PersonHibernateVO(String firstName, String middleName,
String lastName, Set<IEmailAddressVO> emailAddresses,
String createdBy, Date createdDate, String updatedBy,
Date updatedDate) {
super(createdBy, createdDate, updatedBy, updatedDate);
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
this.emailAddresses = emailAddresses;
}
@SequenceGenerator(name = "generator", sequenceName = "PERSON_SEQ")
@Id @GeneratedValue(strategy=SEQUENCE, generator="generator")
@Column(name="ID", nullable=false, updatable=false, insertable=false)
public Long getId(){
return super.id;
}
@Override
public String getFirstName() {
return firstName;
}
@Override
public String getLastName() {
return lastName;
}
@Override
public String getMiddleName() {
return middleName;
}
@Override
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@Override
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
@Override
public Set<IEmailAddressVO> getEmailAddresses() {
return emailAddresses;
}
@Override
public void setEmailAddresses(Set<IEmailAddressVO> emailAddresses) {
this.emailAddresses.clear();
this.emailAddresses.addAll(emailAddresses);
}
}