From: mordicus Date: Fri, 17 Jul 2015 09:19:27 +0000 (+0200) Subject: Fixe entities X-Git-Tag: gde-v0.1~39 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=498d780ea034e7a2c3f06c07e87ea3a02d2f44f9;p=modules%2Fgde.git Fixe entities --- diff --git a/projects/GDE_App/GDE-ejb/nbproject/project.xml b/projects/GDE_App/GDE-ejb/nbproject/project.xml index c07a94a..312bb1d 100644 --- a/projects/GDE_App/GDE-ejb/nbproject/project.xml +++ b/projects/GDE_App/GDE-ejb/nbproject/project.xml @@ -6,10 +6,10 @@ GDE-ejb 1.6.5 - + - + diff --git a/projects/GDE_App/GDE-ejb/src/conf/persistence.xml b/projects/GDE_App/GDE-ejb/src/conf/persistence.xml index 8e8fefc..775e749 100644 --- a/projects/GDE_App/GDE-ejb/src/conf/persistence.xml +++ b/projects/GDE_App/GDE-ejb/src/conf/persistence.xml @@ -1,8 +1,11 @@ + org.eclipse.persistence.jpa.PersistenceProvider jdbc/gdedb false - + + + diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GDEFile.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GDEFile.java index ce7e0a1..580658f 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GDEFile.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GDEFile.java @@ -16,10 +16,13 @@ import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; @@ -53,6 +56,8 @@ public class GDEFile implements Serializable { @Basic(optional = false) @NotNull @Column(name = "id") + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE") + @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50) private long id; @Size(max = 255) @Column(name = "name") @@ -75,8 +80,6 @@ public class GDEFile implements Serializable { @Column(name = "deletion_date") @Temporal(TemporalType.TIMESTAMP) private Date deletionDate; - @OneToMany(cascade = CascadeType.ALL) - private Collection chunkCollection; @Column(name = "attribute_group_id") private long attributeGroupId; @@ -159,15 +162,6 @@ public class GDEFile implements Serializable { this.deletionDate = deletionDate; } - @XmlTransient - public Collection getChunkCollection() { - return chunkCollection; - } - - public void setChunkCollection(Collection chunkCollection) { - this.chunkCollection = chunkCollection; - } - public long getAttributeGroupId() { return attributeGroupId; } @@ -179,12 +173,6 @@ public class GDEFile implements Serializable { public static GDEFile fromFileTO(FileTO fto) { GDEFile f = new GDEFile(); f.checksum = fto.getChecksum(); - - f.chunkCollection = new ArrayList<>(); - Collection chunks = fto.getChunkCollection(); - for (ChunkTO cto : chunks) { - f.chunkCollection.add(Chunk.fromChunkTO(cto)); - } f.creationDate = fto.getCreationDate(); f.deleted = fto.getDeleted(); @@ -201,13 +189,7 @@ public class GDEFile implements Serializable { public FileTO toFileTO() { FileTO fto = new FileTO(); fto.setChecksum(this.checksum); - - Collection ctos = new ArrayList<>(); - for (Chunk c : this.chunkCollection) { - ctos.add(c.toChunkTO()); - } - fto.setChunkCollection(ctos); - + fto.setCreationDate(this.creationDate); fto.setDeleted(this.deleted); fto.setDeletionDate(this.deletionDate); @@ -237,7 +219,6 @@ public class GDEFile implements Serializable { hash = 29 * hash + Objects.hashCode(this.valid); hash = 29 * hash + Objects.hashCode(this.deleted); hash = 29 * hash + Objects.hashCode(this.deletionDate); - hash = 29 * hash + Objects.hashCode(this.chunkCollection); hash = 29 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32)); return hash; } 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 681c30d..6f1fc71 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 @@ -12,11 +12,14 @@ import java.util.Objects; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; @@ -47,6 +50,8 @@ public class Study implements Serializable { @Basic(optional = false) @NotNull @Column(name = "id") + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE") + @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50) private long id; @Size(max = 255) @Column(name = "name") diff --git a/projects/GDE_App/src/GDE_DB_Init.sql b/projects/GDE_App/src/GDE_DB_Init.sql index 905fa03..25d0435 100644 --- a/projects/GDE_App/src/GDE_DB_Init.sql +++ b/projects/GDE_App/src/GDE_DB_Init.sql @@ -1,8 +1,8 @@ -/* + drop sequence SEQ_GEN_SEQUENCE; create sequence SEQ_GEN_SEQUENCE INCREMENT BY 50; -*/ + /* METADATA */ DROP TABLE IF EXISTS attribute_group CASCADE; @@ -20,6 +20,7 @@ CREATE TABLE attribute ( mandatory boolean ); + /* DATA */ DROP TABLE IF EXISTS gde_file CASCADE;