Simple Mappings
Let's begin with the mapping of simple attributes first. From the class diagram, there exists simple
attributes in all three classes. Let's go through them one by one. Listing 9-5 shows the Contact class with
the mapping annotations.
Listing 9-5. The Contact Class
package com.apress.prospring3.ch9.domain;
import static javax.persistence.GenerationType.IDENTITY;
import
java.io.Serializable;
import
java.util.Date;
import
java.util.HashSet;
import
java.util.Set;
import
javax.persistence.*;
@Entity
@Table(name = "contact")
public class Contact implements Serializable {
private
Long id;
private
int version;
private
String firstName;
private
String lastName;
private
Date birthDate;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID")
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
@Version
@Column(name = "VERSION")
public int getVersion() {
return this.version;
}
public void setVersion(int version) {
this.version = version;
}
@Column(name = "FIRST_NAME")
public String getFirstName() {
return this.firstName;
}
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home