hs.hsadmin/hsarback/src/de/hsadmin/mods/dom/DomainOption.java

89 lines
2.0 KiB
Java
Raw Normal View History

2012-07-18 10:53:46 +02:00
package de.hsadmin.mods.dom;
import static javax.persistence.GenerationType.SEQUENCE;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.mods.user.UnixUser;
@Table(name="domain_option")
@Entity(name="DomainOption")
@SequenceGenerator(name = "DomainOptionSeqGen", sequenceName = "domain_option_id_seq")
public class DomainOption extends AbstractEntity {
@Id
@Column(name = "domain_option_id", columnDefinition = "integer")
@GeneratedValue(strategy = SEQUENCE, generator = "DomainOptionSeqGen")
private long id;
@FieldValidation("[a-z0-9]+")
@Column(name = "domain_option_name", columnDefinition = "character varying(256)", nullable = false)
private String name;
@ManyToMany(fetch=FetchType.LAZY)
@JoinTable(name="domain__domain_option",
joinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")},
inverseJoinColumns={@JoinColumn(name="domain_id", referencedColumnName="domain_id")})
private Set<Domain> domains;
@Override
public long id() {
return getId();
}
@Override
public String createStringKey() {
return name;
}
@Override
public boolean isNew() {
return false;
}
@Override
public UnixUser owningUser(EntityManager em) {
// TODO Auto-generated method stub
return null;
}
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 Set<Domain> getDomains() {
return domains;
}
public void setDomains(Set<Domain> domains) {
this.domains = domains;
}
}