Skip to content

Instantly share code, notes, and snippets.

@asicfr
Created October 15, 2012 08:47
Show Gist options
  • Save asicfr/3891507 to your computer and use it in GitHub Desktop.
Save asicfr/3891507 to your computer and use it in GitHub Desktop.
struts2RestJpaBootstrap - vo
package org.demo.vo.bean;
import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.* ;
import org.hibernate.validator.constraints.* ;
@Entity
@Table(name="BOOK", schema="ROOT" )
public class Book implements Serializable
{
private static final long serialVersionUID = 1L;
//----------------------------------------------------------------------
// ENTITY ATTRIBUTES
//----------------------------------------------------------------------
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="ID", nullable=false)
private Integer id;
@Column(name="PUBLISHER_ID", nullable=false)
private Integer publisherId;
@Column(name="AUTHOR_ID", nullable=false)
private Integer authorId;
@Column(name="ISBN", nullable=false, length=13)
@NotNull
@Size( max = 13 )
@NotEmpty
private String isbn;
@Column(name="TITLE", length=160)
@Size( max = 160 )
private String title;
@Column(name="PRICE")
private Double price;
@Column(name="QUANTITY")
private Integer quantity;
@Column(name="DISCOUNT")
private Integer discount;
@Column(name="AVAILABILITY")
private Short availability;
@Column(name="BEST_SELLER")
private Short bestSeller;
//----------------------------------------------------------------------
// ENTITY LINKS ( RELATIONSHIP )
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// CONSTRUCTOR(S)
//----------------------------------------------------------------------
public Book()
{
super();
}
//----------------------------------------------------------------------
// GETTERS & SETTERS FOR ENTITY FIELDS
//----------------------------------------------------------------------
//--- DB PRIMARY KEY : ID ( INTEGER )
public void setId( Integer value )
{
this.id = value;
}
public Integer getId()
{
return this.id;
}
//--- DB COLUMN : PUBLISHER_ID ( INTEGER )
public void setPublisherId( Integer value )
{
this.publisherId = value;
}
public Integer getPublisherId()
{
return this.publisherId;
}
//--- DB COLUMN : AUTHOR_ID ( INTEGER )
public void setAuthorId( Integer value )
{
this.authorId = value;
}
public Integer getAuthorId()
{
return this.authorId;
}
//--- DB COLUMN : ISBN ( VARCHAR )
public void setIsbn( String value )
{
this.isbn = value;
}
public String getIsbn()
{
return this.isbn;
}
//--- DB COLUMN : TITLE ( VARCHAR )
public void setTitle( String value )
{
this.title = value;
}
public String getTitle()
{
return this.title;
}
//--- DB COLUMN : PRICE ( DECIMAL )
public void setPrice( Double value )
{
this.price = value;
}
public Double getPrice()
{
return this.price;
}
//--- DB COLUMN : QUANTITY ( INTEGER )
public void setQuantity( Integer value )
{
this.quantity = value;
}
public Integer getQuantity()
{
return this.quantity;
}
//--- DB COLUMN : DISCOUNT ( INTEGER )
public void setDiscount( Integer value )
{
this.discount = value;
}
public Integer getDiscount()
{
return this.discount;
}
//--- DB COLUMN : AVAILABILITY ( SMALLINT )
public void setAvailability( Short value )
{
this.availability = value;
}
public Short getAvailability()
{
return this.availability;
}
//--- DB COLUMN : BEST_SELLER ( SMALLINT )
public void setBestSeller( Short value )
{
this.bestSeller = value;
}
public Short getBestSeller()
{
return this.bestSeller;
}
//----------------------------------------------------------------------
// GETTERS & SETTERS FOR LINKS
//----------------------------------------------------------------------
//----------------------------------------------------------------------
// SPECIFIC toString METHOD
//----------------------------------------------------------------------
public String toString()
{
StringBuffer sb = new StringBuffer();
sb.append(id);
sb.append("|");
sb.append(publisherId);
sb.append("|");
sb.append(authorId);
sb.append("|");
sb.append(isbn);
sb.append("|");
sb.append(title);
sb.append("|");
sb.append(price);
sb.append("|");
sb.append(quantity);
sb.append("|");
sb.append(discount);
sb.append("|");
sb.append(availability);
sb.append("|");
sb.append(bestSeller);
return sb.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment