View Javadoc
1   package ejava.jpa.example.validation;
2   
3   /**
4    * This class provides an example of using an XML descriptor to define
5    * constraints
6    */
7   public class Book {
8   	private int id;
9   	
10  	//@NotNull(message="title is required")
11  	//@Size(max=32, message="title too long")
12  	private String title;
13  	//@Min(value=1, message="pages are required")
14  	private int pages;
15  	
16  	public int getId() { return id; }
17  
18  	public String getTitle() { return title; }
19  	public Book setTitle(String title) {
20  		this.title = title;
21  		return this;
22  	}
23  	
24  	public int getPages() { return pages; }
25  	public Book setPages(int pages) {
26  		this.pages = pages;
27  		return this;
28  	}
29  	
30  	@Override
31  	public String toString() {
32  		return title + " " + pages + "pp";
33  	}
34  }