/**
* Author: Bob Chen
* Kylin Soong
*/
package com.jcommerce.core.model;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "card")
public class Card extends ModelObject {
private Long id;
@Id
@GeneratedValue
@Basic(optional = false)
@Column(name = "id", nullable = false)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
private static final long serialVersionUID = 7751500108299020424L;
private String name;
private String description;
private String image;
private double fee;
private double freeMoney;
private Set<Order> orders = new HashSet<Order>();
@Basic( optional = true )
@Column( name = "card_name", length = 120 )
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Basic( optional = true )
@Column( name = "card_desc", length = 255 )
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Basic( optional = true )
@Column( name = "card_img", length = 255 )
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
@Basic( optional = true )
@Column( name = "card_fee" )
public double getFee() {
return fee;
}
public void setFee(double fee) {
this.fee = fee;
}
@Basic( optional = true )
@Column( name = "free_money" )
public double getFreeMoney() {
return freeMoney;
}
public void setFreeMoney(double freeMoney) {
this.freeMoney = freeMoney;
}
@OneToMany( fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE }, mappedBy = "card" )
@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
@Basic( optional = false )
@Column( name = "card_id", nullable = false )
public Set<Order> getOrders() {
return this.orders;
}
public void addOrder(Order order) {
order.setCard(this);
this.orders.add(order);
}
public void setOrders(final Set<Order> order) {
this.orders = order;
}
}