Added missing table-name + table columns in a match period should be not null.

This commit is contained in:
Tom Vahlman 2012-02-17 17:53:28 +01:00
parent b1bb91f87f
commit db4805bae8
2 changed files with 13 additions and 5 deletions
resources/db_update_scripts
src/main/java/se/su/dsv/scipro/match/dataobject

@ -0,0 +1,5 @@
-- it is not possible to set a proper default DATETIME in mysql so we settle for "0", the sql works irrespective if the table are empty or not
ALTER TABLE `ApplicationPeriod` CHANGE `startDate` `startDate` DATETIME NOT NULL DEFAULT 0,
CHANGE `endDate` `endDate` DATETIME NOT NULL DEFAULT 0,
CHANGE `name` `name` varchar(255) NOT NULL

@ -4,11 +4,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Cacheable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.*;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
@ -19,6 +15,7 @@ import se.su.dsv.scipro.data.dataobjects.ProjectClass;
@Entity
@Cacheable(true)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Table(name="ApplicationPeriod")
// Hibernate specific
public class ApplicationPeriod extends DomainObject {
@ -31,9 +28,15 @@ public class ApplicationPeriod extends DomainObject {
@ManyToMany
private Set<ProjectClass> projectClass = new HashSet<ProjectClass>();
@Basic(optional = false)
private String name;
@Basic(optional = false)
@Temporal(TemporalType.DATE)
private Date startDate;
@Basic(optional = false)
@Temporal(TemporalType.DATE)
private Date endDate;
public ApplicationPeriod() {