package hello.models;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.Size;

@Entity
public class Greeting implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue
	private long id;

	@Size(min = 1, max = 30)
	private String template;

	public Greeting() {
	}

	public Greeting(String template) {
		this.template = template;
	}

	public long getId() {
		return this.id;
	}

	public String getTemplate() {
		return this.template;
	}

	public void setTemplate(String template) {
		this.template = template;
	}

	public String getGreeting(String name) {
		return String.format(this.template, name);
	}

	@Override
	public String toString() {
		return String.format("Greeting [id = %d, template = %s]", this.id, this.template);
	}
}

@@ -192,16 +192,70 @@
 .Size;%0A%0A
+import org.hibernate.validator.constraints.NotEmpty;%0A%0A
 @Entity%0A
@@ -399,16 +399,70 @@
 d;%0A%0A
+%09@NotEmpty(message = %22The greeting cannot be empty.%22)%0A
 %09@Size(m
 in =
@@ -461,24 +461,74 @@
 ze(m
-in = 1, max = 30
+ax = 30, message = %22The greeting must have 30 characters or less.%22
 )%0A%09p

Improve the greeting template validation and messages.