From db93717d502cb070a748e720d07c31d3d285f098 Mon Sep 17 00:00:00 2001 From: mordicus Date: Mon, 3 Aug 2015 17:06:31 +0200 Subject: [PATCH] Created "Group" entity and TO --- .../src/java/com/edf/gde/entities/Group.java | 69 +++++++++++++++++++ .../com/edf/gde/transferables/GroupTO.java | 29 ++++++++ 2 files changed, 98 insertions(+) create mode 100644 projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Group.java create mode 100644 projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/GroupTO.java diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Group.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Group.java new file mode 100644 index 0000000..fdde052 --- /dev/null +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Group.java @@ -0,0 +1,69 @@ +package com.edf.gde.entities; + +import com.edf.gde.transferables.GroupTO; +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.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * + * @author kavoos + */ +@Entity(name = "Group") +@Table(name = "GROUP_") +@NamedQueries({ + @NamedQuery(name = "Group.findById", query = "SELECT g FROM Group g"), + @NamedQuery(name = "Group.findByName", query = "SELECT g FROM Group g where g.name=:name") +}) + +public class Group { + @Id + @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 = "groupName") + private String name; + + 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 static Group fromGroupTO(GroupTO groupTO) { + Group g = new Group(); + g.setId(groupTO.getId()); + g.setName(groupTO.getName()); + return g; + } + + public GroupTO toGroupTO() { + GroupTO groupTO = new GroupTO(); + groupTO.setId(id); + groupTO.setName(name); + return groupTO; + } +} diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/GroupTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/GroupTO.java new file mode 100644 index 0000000..3b8d47d --- /dev/null +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/GroupTO.java @@ -0,0 +1,29 @@ +package com.edf.gde.transferables; + +/** + * + * @author kavoos + */ +public class GroupTO { + private long id; + private String name; + + public GroupTO() { + } + + 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; + } +} -- 2.39.2