package fi.otavanopisto.pyramus.domainmodel.base; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; import javax.persistence.Lob; import javax.persistence.OneToOne; import javax.persistence.TableGenerator; import javax.persistence.Version; import javax.validation.constraints.NotNull; import org.hibernate.search.annotations.DocumentId; import org.hibernate.search.annotations.Field; import org.hibernate.validator.constraints.NotEmpty; @Entity @Inheritance(strategy=InheritanceType.JOINED) public abstract class ComponentBase implements ArchivableEntity { public Long getId() { return id; } public void setName(String name) { this.name = name; } public String getName() { return name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public EducationalLength getLength() { return length; } public void setLength(EducationalLength length) { this.length = length; } public void setArchived(Boolean archived) { this.archived = archived; } public Boolean getArchived() { return archived; } @SuppressWarnings("unused") private void setVersion(Long version) { this.version = version; } public Long getVersion() { return version; } @Id @DocumentId @GeneratedValue(strategy=GenerationType.TABLE, generator="ComponentBase") @TableGenerator(name="ComponentBase", allocationSize=1, table = "hibernate_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_next_hi_value") private Long id; @NotNull @Column (nullable = false) @NotEmpty @Field private String name; @Lob @Basic (fetch = FetchType.LAZY) @Column @Field private String description; @OneToOne (cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn (name = "length") private EducationalLength length = new EducationalLength(); @NotNull @Column(nullable = false) @Field private Boolean archived = Boolean.FALSE; @Version @Column(nullable = false) private Long version; }