Skip to content

Instantly share code, notes, and snippets.

@dbonillaf
Created June 1, 2010 16:49
Show Gist options
  • Save dbonillaf/421145 to your computer and use it in GitHub Desktop.
Save dbonillaf/421145 to your computer and use it in GitHub Desktop.
package com.six.model.entity;
import java.io.Serializable;
import javax.persistence.*;
import static javax.persistence.CascadeType.*;
import java.util.Collection;
import java.util.ArrayList;
@Entity
@NamedQueries({
@NamedQuery(name = "Customer.findById", query = "SELECT u FROM Customer u WHERE u.id = :id")})
public class Customer implements Serializable {
private int id;
private String name;
private Collection<Order> orders = new ArrayList<Order>();
private int version;
@Id
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@OneToMany(cascade=ALL, mappedBy="customer")
public Collection<Order> getOrders() {
return orders;
}
public void setOrders(Collection<Order> newValue) {
this.orders = newValue;
}
@Version
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment