From 9a83dd66937c2e5ed717f05f22f98846628eea34 Mon Sep 17 00:00:00 2001 From: Bojnourdi Date: Thu, 27 Aug 2015 10:30:54 +0200 Subject: [PATCH] Work on entities for automatic DDL generation --- .../src/java/com/edf/gde/entities/Chunk.java | 2 +- .../src/java/com/edf/gde/entities/Study.java | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Chunk.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Chunk.java index d360865..f7ebec6 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Chunk.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Chunk.java @@ -52,7 +52,7 @@ public class Chunk implements Serializable { @Column(name = "size") private long size; @Lob - @Column(name = "data") + @Column(name = "data",nullable = false) private byte[] data; public Chunk() { diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java index 67d633b..2444a68 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java @@ -74,8 +74,9 @@ public class Study implements Serializable { @OneToOne(fetch = FetchType.LAZY,optional = true) @JoinColumn(name = "attribute_group_id", nullable = true) private AttributeGroup attributeGroup; - @Column(name = "profile_id", nullable = true) - private Long profileId; + @OneToOne(fetch = FetchType.LAZY, optional = true) + @JoinColumn(name = "profile_id", nullable = true) + private Profile profile; @Column(name = "locked") private boolean locked; @Column(name = "lock_owner") @@ -159,12 +160,12 @@ public class Study implements Serializable { this.attributeGroup = attributeGroup; } - public long getProfileId() { - return profileId; + public Profile getProfile() { + return profile; } - public void setProfileId(long profileId) { - this.profileId = profileId; + public void setProfile(Profile profile) { + this.profile = profile; } public boolean isLocked() { @@ -201,7 +202,7 @@ public class Study implements Serializable { s.name = sto.getName(); s.updateDate = sto.getUpdateDate(); s.valid = sto.getValid(); - s.profileId = sto.getProfileId() == 0 ? null : sto.getProfileId(); + s.profile = sto.getProfileId() == 0 ? null : em.find(Profile.class,sto.getProfileId()); s.locked = sto.isLocked(); s.lockOwner = sto.getLockOwner() == 0 ? null : sto.getLockOwner(); return s; @@ -217,7 +218,7 @@ public class Study implements Serializable { sto.setName(this.name); sto.setUpdateDate(this.updateDate); sto.setValid(this.valid); - sto.setProfileId(this.profileId == null ? 0 : this.profileId); + sto.setProfileId(this.profile == null ? 0 : this.profile.getId()); sto.setLocked(this.locked); sto.setLockOwner(this.lockOwner == null ? 0 : this.lockOwner); return sto; @@ -238,7 +239,6 @@ public class Study implements Serializable { hash = 67 * hash + (this.valid ? 1 : 0); hash = 67 * hash + (this.deleted ? 1 : 0); hash = 67 * hash + Objects.hashCode(this.deletionDate); - hash = 67 * hash + Objects.hashCode(this.profileId); hash = 67 * hash + (this.locked ? 1 : 0); return hash; } -- 2.39.2