Skip to content

Instantly share code, notes, and snippets.

@hseritt
Created June 27, 2016 01:54
Show Gist options
  • Save hseritt/8a2eb3c6ad4fdb26428e18d88088fe9d to your computer and use it in GitHub Desktop.
Save hseritt/8a2eb3c6ad4fdb26428e18d88088fe9d to your computer and use it in GitHub Desktop.
Jpa Table and Model (unique constraints)
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
@Entity
@Table(name="Agent", uniqueConstraints={@UniqueConstraint(columnNames={"name"})})
public class Agent {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Column(name="name")
private String name;
@Column(name="description")
private String description;
@Column(name="class_name")
private String className;
@Column(name="active")
private boolean active;
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment