Commit d8809b16 by Tuukka Kivilahti

Merge branch 'master' of tkfftk@dev.intra.insomnia.fi:/data/bortal

2 parents 83778216 fbab0d85
Showing with 531 additions and 451 deletions
...@@ -43,10 +43,9 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal { ...@@ -43,10 +43,9 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal {
return false; return false;
} }
private static boolean getRights(Role role,String target,RolePermission permission, Set<Role> checkedRoles) { private static boolean getRights(Role role, String target, RolePermission permission, Set<Role> checkedRoles) {
if(checkedRoles.contains(role)) if (checkedRoles.contains(role)) {
{
return false; return false;
} }
...@@ -73,8 +72,7 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal { ...@@ -73,8 +72,7 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal {
checkedRoles.add(role); checkedRoles.add(role);
for (Role r : role.getParents()) { for (Role r : role.getParents()) {
if(getRights(r,target,permission,checkedRoles)) if (getRights(r, target, permission, checkedRoles)) {
{
return true; return true;
} }
......
...@@ -7,7 +7,6 @@ package fi.insomnia.bortal.model; ...@@ -7,7 +7,6 @@ package fi.insomnia.bortal.model;
import java.util.List; import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
...@@ -28,7 +27,7 @@ import javax.persistence.Version; ...@@ -28,7 +27,7 @@ import javax.persistence.Version;
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "AccessRight.findAll", query = "SELECT a FROM AccessRight a"), @NamedQuery(name = "AccessRight.findAll", query = "SELECT a FROM AccessRight a"),
@NamedQuery(name = "AccessRight.findByName", query = "SELECT a FROM AccessRight a WHERE a.name = :name") }) @NamedQuery(name = "AccessRight.findByName", query = "SELECT a FROM AccessRight a WHERE a.name = :name") })
public class AccessRight implements ModelInterface { public class AccessRight implements ModelInterface<Integer>{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
......
...@@ -10,11 +10,10 @@ import java.util.Calendar; ...@@ -10,11 +10,10 @@ import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -36,13 +35,11 @@ import javax.persistence.Version; ...@@ -36,13 +35,11 @@ import javax.persistence.Version;
@NamedQuery(name = "AccountEvent.findByUnits", query = "SELECT a FROM AccountEvent a WHERE a.units = :units"), @NamedQuery(name = "AccountEvent.findByUnits", query = "SELECT a FROM AccountEvent a WHERE a.units = :units"),
@NamedQuery(name = "AccountEvent.findByEventTime", query = "SELECT a FROM AccountEvent a WHERE a.eventTime = :eventTime"), @NamedQuery(name = "AccountEvent.findByEventTime", query = "SELECT a FROM AccountEvent a WHERE a.eventTime = :eventTime"),
@NamedQuery(name = "AccountEvent.findByDelivered", query = "SELECT a FROM AccountEvent a WHERE a.delivered = :delivered") }) @NamedQuery(name = "AccountEvent.findByDelivered", query = "SELECT a FROM AccountEvent a WHERE a.delivered = :delivered") })
public class AccountEvent implements ModelInterface { public class AccountEvent implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "account_events_id", nullable = false)
private Integer id;
@Column(name = "unit_price", nullable = false, precision = 24, scale = 4) @Column(name = "unit_price", nullable = false, precision = 24, scale = 4)
private BigDecimal unitPrice; private BigDecimal unitPrice;
...@@ -58,11 +55,17 @@ public class AccountEvent implements ModelInterface { ...@@ -58,11 +55,17 @@ public class AccountEvent implements ModelInterface {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar delivered; private Calendar delivered;
@JoinColumn(name = "food_waves_id", referencedColumnName = "food_waves_id") @JoinColumns({
@JoinColumn(name = "food_waves_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="food_waves_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne @ManyToOne
private FoodWave foodWave; private FoodWave foodWave;
@JoinColumn(name = "products_id", referencedColumnName = "products_id", nullable = false) @JoinColumns({
@JoinColumn(name = "products_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="products_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Product product; private Product product;
...@@ -77,6 +80,10 @@ public class AccountEvent implements ModelInterface { ...@@ -77,6 +80,10 @@ public class AccountEvent implements ModelInterface {
@OneToMany(mappedBy = "accountEvent") @OneToMany(mappedBy = "accountEvent")
private List<DiscountInstance> discountInstances; private List<DiscountInstance> discountInstances;
@JoinColumns({
@JoinColumn(name = "bill_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="bill_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@OneToOne @OneToOne
private Bill bill; private Bill bill;
...@@ -85,12 +92,12 @@ public class AccountEvent implements ModelInterface { ...@@ -85,12 +92,12 @@ public class AccountEvent implements ModelInterface {
private int jpaVersionField; private int jpaVersionField;
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
...@@ -107,11 +114,11 @@ public class AccountEvent implements ModelInterface { ...@@ -107,11 +114,11 @@ public class AccountEvent implements ModelInterface {
public AccountEvent() { public AccountEvent() {
} }
public AccountEvent(Integer accountEventsId) { public AccountEvent(EventPk accountEventsId) {
this.id = accountEventsId; this.id = accountEventsId;
} }
public AccountEvent(Integer accountEventsId, BigDecimal unitPrice, public AccountEvent(EventPk accountEventsId, BigDecimal unitPrice,
BigDecimal unitCount, Calendar eventTime) { BigDecimal unitCount, Calendar eventTime) {
this.id = accountEventsId; this.id = accountEventsId;
this.setUnitPrice(unitPrice); this.setUnitPrice(unitPrice);
......
...@@ -8,11 +8,10 @@ import java.util.Calendar; ...@@ -8,11 +8,10 @@ import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -38,14 +37,13 @@ import javax.persistence.Version; ...@@ -38,14 +37,13 @@ import javax.persistence.Version;
@NamedQuery(name = "Bill.findByPaidDate", query = "SELECT b FROM Bill b WHERE b.paidDate = :paidDate"), @NamedQuery(name = "Bill.findByPaidDate", query = "SELECT b FROM Bill b WHERE b.paidDate = :paidDate"),
@NamedQuery(name = "Bill.findByReferenceNumber", query = "SELECT b FROM Bill b WHERE b.referenceNumber = :referenceNumber"), @NamedQuery(name = "Bill.findByReferenceNumber", query = "SELECT b FROM Bill b WHERE b.referenceNumber = :referenceNumber"),
@NamedQuery(name = "Bill.findByNotes", query = "SELECT b FROM Bill b WHERE b.notes = :notes") }) @NamedQuery(name = "Bill.findByNotes", query = "SELECT b FROM Bill b WHERE b.notes = :notes") })
public class Bill implements ModelInterface { public class Bill implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;;
@Column(name = "bills_id", nullable = false)
private Integer id;
@Column(name = "due_date") @Column(name = "due_date")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
...@@ -65,10 +63,13 @@ public class Bill implements ModelInterface { ...@@ -65,10 +63,13 @@ public class Bill implements ModelInterface {
@OneToMany(mappedBy = "bill") @OneToMany(mappedBy = "bill")
private List<BillLine> billLines; private List<BillLine> billLines;
@JoinColumn(name = "accout_events_id", referencedColumnName = "account_events_id") @JoinColumns({
@JoinColumn(name = "account_event_id", referencedColumnName = "entity_id", nullable = false, updatable=false,insertable=false),
@JoinColumn(name = "account_event_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable=false,insertable=false) })
@OneToOne @OneToOne
private AccountEvent accountEvent; private AccountEvent accountEvent;
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false) @JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private User user; private User user;
...@@ -80,12 +81,12 @@ public class Bill implements ModelInterface { ...@@ -80,12 +81,12 @@ public class Bill implements ModelInterface {
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
...@@ -98,7 +99,7 @@ public class Bill implements ModelInterface { ...@@ -98,7 +99,7 @@ public class Bill implements ModelInterface {
public Bill() { public Bill() {
} }
public Bill(Integer billsId) { public Bill(EventPk billsId) {
this.id = billsId; this.id = billsId;
} }
......
...@@ -8,11 +8,10 @@ package fi.insomnia.bortal.model; ...@@ -8,11 +8,10 @@ package fi.insomnia.bortal.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -30,13 +29,11 @@ import javax.persistence.Version; ...@@ -30,13 +29,11 @@ import javax.persistence.Version;
@NamedQuery(name = "BillLine.findByUnits", query = "SELECT b FROM BillLine b WHERE b.units = :units"), @NamedQuery(name = "BillLine.findByUnits", query = "SELECT b FROM BillLine b WHERE b.units = :units"),
@NamedQuery(name = "BillLine.findByUnitPrice", query = "SELECT b FROM BillLine b WHERE b.unitPrice = :unitPrice"), @NamedQuery(name = "BillLine.findByUnitPrice", query = "SELECT b FROM BillLine b WHERE b.unitPrice = :unitPrice"),
@NamedQuery(name = "BillLine.findByVat", query = "SELECT b FROM BillLine b WHERE b.vat = :vat") }) @NamedQuery(name = "BillLine.findByVat", query = "SELECT b FROM BillLine b WHERE b.vat = :vat") })
public class BillLine implements ModelInterface { public class BillLine implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final BigDecimal DEFAULT_VAT = BigDecimal.ZERO; private static final BigDecimal DEFAULT_VAT = BigDecimal.ZERO;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "bill_lines_id", nullable = false)
private Integer id;
@Column(name = "name", nullable = false) @Column(name = "name", nullable = false)
private String name; private String name;
...@@ -50,7 +47,11 @@ public class BillLine implements ModelInterface { ...@@ -50,7 +47,11 @@ public class BillLine implements ModelInterface {
@Column(name = "vat", nullable = false, precision = 3, scale = 2) @Column(name = "vat", nullable = false, precision = 3, scale = 2)
private BigDecimal vat = DEFAULT_VAT; private BigDecimal vat = DEFAULT_VAT;
@JoinColumn(name = "bills_id", referencedColumnName = "bills_id") @JoinColumns({
@JoinColumn(name = "bills_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="bills_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne @ManyToOne
private Bill bill; private Bill bill;
...@@ -61,11 +62,11 @@ public class BillLine implements ModelInterface { ...@@ -61,11 +62,11 @@ public class BillLine implements ModelInterface {
public BillLine() { public BillLine() {
} }
public BillLine(Integer billLinesId) { public BillLine(EventPk billLinesId) {
this.id = billLinesId; this.id = billLinesId;
} }
public BillLine(Integer billLinesId, String product, BigDecimal units, public BillLine(EventPk billLinesId, String product, BigDecimal units,
BigDecimal unitPrice, BigDecimal vat) { BigDecimal unitPrice, BigDecimal vat) {
this.id = billLinesId; this.id = billLinesId;
this.name = product; this.name = product;
...@@ -128,12 +129,12 @@ public class BillLine implements ModelInterface { ...@@ -128,12 +129,12 @@ public class BillLine implements ModelInterface {
} }
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -8,10 +8,8 @@ package fi.insomnia.bortal.model; ...@@ -8,10 +8,8 @@ package fi.insomnia.bortal.model;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
...@@ -30,12 +28,10 @@ import javax.persistence.Version; ...@@ -30,12 +28,10 @@ import javax.persistence.Version;
@NamedQuery(name = "CardTemplate.findAll", query = "SELECT c FROM CardTemplate c"), @NamedQuery(name = "CardTemplate.findAll", query = "SELECT c FROM CardTemplate c"),
@NamedQuery(name = "CardTemplate.findByName", query = "SELECT c FROM CardTemplate c WHERE c.name = :name") }) @NamedQuery(name = "CardTemplate.findByName", query = "SELECT c FROM CardTemplate c WHERE c.name = :name") })
public class CardTemplate implements ModelInterface { public class CardTemplate implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "card_templates_id", nullable = false)
private Integer id;
@Lob @Lob
@Column(name = "template_image") @Column(name = "template_image")
...@@ -61,11 +57,11 @@ public class CardTemplate implements ModelInterface { ...@@ -61,11 +57,11 @@ public class CardTemplate implements ModelInterface {
public CardTemplate() { public CardTemplate() {
} }
public CardTemplate(Integer cardTemplatesId) { public CardTemplate(EventPk cardTemplatesId) {
this.id = cardTemplatesId; this.id = cardTemplatesId;
} }
public CardTemplate(Integer cardTemplatesId, String templateName) { public CardTemplate(EventPk cardTemplatesId, String templateName) {
this.id = cardTemplatesId; this.id = cardTemplatesId;
this.name = templateName; this.name = templateName;
} }
...@@ -91,12 +87,12 @@ public class CardTemplate implements ModelInterface { ...@@ -91,12 +87,12 @@ public class CardTemplate implements ModelInterface {
} }
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -10,10 +10,8 @@ import java.util.List; ...@@ -10,10 +10,8 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
...@@ -41,12 +39,10 @@ import javax.persistence.Version; ...@@ -41,12 +39,10 @@ import javax.persistence.Version;
@NamedQuery(name = "Compo.findBySubmitEnd", query = "SELECT c FROM Compo c WHERE c.submitEnd = :submitEnd"), @NamedQuery(name = "Compo.findBySubmitEnd", query = "SELECT c FROM Compo c WHERE c.submitEnd = :submitEnd"),
@NamedQuery(name = "Compo.findByHoldVoting", query = "SELECT c FROM Compo c WHERE c.holdVoting = :holdVoting"), @NamedQuery(name = "Compo.findByHoldVoting", query = "SELECT c FROM Compo c WHERE c.holdVoting = :holdVoting"),
@NamedQuery(name = "Compo.findByDescription", query = "SELECT c FROM Compo c WHERE c.description = :description") }) @NamedQuery(name = "Compo.findByDescription", query = "SELECT c FROM Compo c WHERE c.description = :description") })
public class Compo implements ModelInterface { public class Compo implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "compos_id", nullable = false)
private Integer id;
@Column(name = "compo_name", nullable = false) @Column(name = "compo_name", nullable = false)
private String name; private String name;
...@@ -94,23 +90,23 @@ public class Compo implements ModelInterface { ...@@ -94,23 +90,23 @@ public class Compo implements ModelInterface {
private int jpaVersionField; private int jpaVersionField;
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
public Compo() { public Compo() {
} }
public Compo(Integer composId) { public Compo(EventPk composId) {
this.id = composId; this.id = composId;
} }
public Compo(Integer composId, String compoName, boolean holdVoting) { public Compo(EventPk composId, String compoName, boolean holdVoting) {
this.id = composId; this.id = composId;
this.name = compoName; this.name = compoName;
this.holdVoting = holdVoting; this.holdVoting = holdVoting;
......
...@@ -10,11 +10,10 @@ import java.util.List; ...@@ -10,11 +10,10 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -33,18 +32,15 @@ import javax.persistence.Version; ...@@ -33,18 +32,15 @@ import javax.persistence.Version;
@Table(name = "entries") @Table(name = "entries")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "CompoEntry.findAll", query = "SELECT c FROM CompoEntry c"), @NamedQuery(name = "CompoEntry.findAll", query = "SELECT c FROM CompoEntry c"),
@NamedQuery(name = "CompoEntry.findByCreated", query = "SELECT c FROM CompoEntry c WHERE c.created = :created"), @NamedQuery(name = "CompoEntry.findByCreated", query = "SELECT c FROM CompoEntry c WHERE c.created = :created"),
@NamedQuery(name = "CompoEntry.findByName", query = "SELECT c FROM CompoEntry c WHERE c.name = :name"), @NamedQuery(name = "CompoEntry.findByName", query = "SELECT c FROM CompoEntry c WHERE c.name = :name"),
@NamedQuery(name = "CompoEntry.findByNotes", query = "SELECT c FROM CompoEntry c WHERE c.notes = :notes"), @NamedQuery(name = "CompoEntry.findByNotes", query = "SELECT c FROM CompoEntry c WHERE c.notes = :notes"),
@NamedQuery(name = "CompoEntry.findByScreenMessage", query = "SELECT c FROM CompoEntry c WHERE c.screenMessage = :screenMessage"), @NamedQuery(name = "CompoEntry.findByScreenMessage", query = "SELECT c FROM CompoEntry c WHERE c.screenMessage = :screenMessage"),
@NamedQuery(name = "CompoEntry.findBySort", query = "SELECT c FROM CompoEntry c WHERE c.sort = :sort") }) @NamedQuery(name = "CompoEntry.findBySort", query = "SELECT c FROM CompoEntry c WHERE c.sort = :sort") })
public class CompoEntry implements ModelInterface { public class CompoEntry implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "entries_id", nullable = false)
private Integer id;
@Column(name = "entry_created", nullable = false) @Column(name = "entry_created", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
...@@ -67,6 +63,10 @@ public class CompoEntry implements ModelInterface { ...@@ -67,6 +63,10 @@ public class CompoEntry implements ModelInterface {
@Column(name = "final_position") @Column(name = "final_position")
private Integer finalPosition; private Integer finalPosition;
@JoinColumns({
@JoinColumn(name = "currentFile_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="currentFile_event_id",referencedColumnName = "events_pk_id",nullable=false, updatable=false,insertable=false)
})
@OneToOne @OneToOne
private CompoEntryFile currentFile; private CompoEntryFile currentFile;
...@@ -79,11 +79,14 @@ public class CompoEntry implements ModelInterface { ...@@ -79,11 +79,14 @@ public class CompoEntry implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry") @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
private List<CompoEntryParticipant> participants; private List<CompoEntryParticipant> participants;
@JoinColumn(name = "compos_id", referencedColumnName = "compos_id", nullable = false) @JoinColumns({
@JoinColumn(name = "compos_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="compos_event_id",referencedColumnName = "events_pk_id",nullable=false, updatable=false,insertable=false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Compo compo; private Compo compo;
@JoinColumn(name = "creator", referencedColumnName = "users_id") @JoinColumn(name = "creator_id", referencedColumnName = "users_id")
@ManyToOne @ManyToOne
private User creator; private User creator;
...@@ -92,23 +95,23 @@ public class CompoEntry implements ModelInterface { ...@@ -92,23 +95,23 @@ public class CompoEntry implements ModelInterface {
private int jpaVersionField; private int jpaVersionField;
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
public CompoEntry() { public CompoEntry() {
} }
public CompoEntry(Integer entriesId) { public CompoEntry(EventPk entriesId) {
this.id = entriesId; this.id = entriesId;
} }
public CompoEntry(Integer entriesId, Calendar entryCreated, String entryName) { public CompoEntry(EventPk entriesId, Calendar entryCreated, String entryName) {
this.id = entriesId; this.id = entriesId;
this.created = entryCreated; this.created = entryCreated;
this.name = entryName; this.name = entryName;
......
...@@ -8,11 +8,10 @@ package fi.insomnia.bortal.model; ...@@ -8,11 +8,10 @@ package fi.insomnia.bortal.model;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -29,18 +28,15 @@ import javax.persistence.Version; ...@@ -29,18 +28,15 @@ import javax.persistence.Version;
@Table(name = "entry_files") @Table(name = "entry_files")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "CompoEntryFile.findAll", query = "SELECT c FROM CompoEntryFile c"), @NamedQuery(name = "CompoEntryFile.findAll", query = "SELECT c FROM CompoEntryFile c"),
@NamedQuery(name = "CompoEntryFile.findByMimeType", query = "SELECT c FROM CompoEntryFile c WHERE c.mimeType = :mimeType"), @NamedQuery(name = "CompoEntryFile.findByMimeType", query = "SELECT c FROM CompoEntryFile c WHERE c.mimeType = :mimeType"),
@NamedQuery(name = "CompoEntryFile.findByFileName", query = "SELECT c FROM CompoEntryFile c WHERE c.fileName = :fileName"), @NamedQuery(name = "CompoEntryFile.findByFileName", query = "SELECT c FROM CompoEntryFile c WHERE c.fileName = :fileName"),
@NamedQuery(name = "CompoEntryFile.findByDescription", query = "SELECT c FROM CompoEntryFile c WHERE c.description = :description"), @NamedQuery(name = "CompoEntryFile.findByDescription", query = "SELECT c FROM CompoEntryFile c WHERE c.description = :description"),
@NamedQuery(name = "CompoEntryFile.findByHash", query = "SELECT c FROM CompoEntryFile c WHERE c.hash = :hash"), @NamedQuery(name = "CompoEntryFile.findByHash", query = "SELECT c FROM CompoEntryFile c WHERE c.hash = :hash"),
@NamedQuery(name = "CompoEntryFile.findByUploaded", query = "SELECT c FROM CompoEntryFile c WHERE c.uploaded = :uploaded") }) @NamedQuery(name = "CompoEntryFile.findByUploaded", query = "SELECT c FROM CompoEntryFile c WHERE c.uploaded = :uploaded") })
public class CompoEntryFile implements ModelInterface { public class CompoEntryFile implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "entry_files_id", nullable = false)
private Integer id;
@Column(name = "mime_type") @Column(name = "mime_type")
private String mimeType; private String mimeType;
...@@ -63,7 +59,10 @@ public class CompoEntryFile implements ModelInterface { ...@@ -63,7 +59,10 @@ public class CompoEntryFile implements ModelInterface {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar uploaded; private Calendar uploaded;
@JoinColumn(name = "entries_id", referencedColumnName = "entries_id", nullable = false) @JoinColumns({
@JoinColumn(name = "entries_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="entries_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private CompoEntry entry; private CompoEntry entry;
...@@ -72,23 +71,23 @@ public class CompoEntryFile implements ModelInterface { ...@@ -72,23 +71,23 @@ public class CompoEntryFile implements ModelInterface {
private int jpaVersionField; private int jpaVersionField;
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
public CompoEntryFile() { public CompoEntryFile() {
} }
public CompoEntryFile(Integer entryFilesId) { public CompoEntryFile(EventPk entryFilesId) {
this.id = entryFilesId; this.id = entryFilesId;
} }
public CompoEntryFile(Integer entryFilesId, Calendar uploaded) { public CompoEntryFile(EventPk entryFilesId, Calendar uploaded) {
this.id = entryFilesId; this.id = entryFilesId;
this.uploaded = uploaded; this.uploaded = uploaded;
} }
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
package fi.insomnia.bortal.model; package fi.insomnia.bortal.model;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -29,13 +29,11 @@ import javax.persistence.Version; ...@@ -29,13 +29,11 @@ import javax.persistence.Version;
@NamedQuery(name = "CompoEntryParticipant.findAll", query = "SELECT c FROM CompoEntryParticipant c"), @NamedQuery(name = "CompoEntryParticipant.findAll", query = "SELECT c FROM CompoEntryParticipant c"),
@NamedQuery(name = "CompoEntryParticipant.findByRole", query = "SELECT c FROM CompoEntryParticipant c WHERE c.role = :role") }) @NamedQuery(name = "CompoEntryParticipant.findByRole", query = "SELECT c FROM CompoEntryParticipant c WHERE c.role = :role") })
public class CompoEntryParticipant implements ModelInterface { public class CompoEntryParticipant implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "entry_participations_id", nullable = false)
private Integer id;
@Column(name = "role") @Column(name = "role")
private String role; private String role;
...@@ -48,11 +46,19 @@ public class CompoEntryParticipant implements ModelInterface { ...@@ -48,11 +46,19 @@ public class CompoEntryParticipant implements ModelInterface {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar confirmed; private Calendar confirmed;
@JoinColumn(name = "entries_id", referencedColumnName = "entries_id", nullable = false) @JoinColumns({
@JoinColumn(name = "entries_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="entries_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private CompoEntry entry; private CompoEntry entry;
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false) @JoinColumns({
@JoinColumn(name = "users_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="users_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private User users; private User users;
...@@ -61,12 +67,12 @@ public class CompoEntryParticipant implements ModelInterface { ...@@ -61,12 +67,12 @@ public class CompoEntryParticipant implements ModelInterface {
private int jpaVersionField; private int jpaVersionField;
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
...@@ -89,7 +95,7 @@ public class CompoEntryParticipant implements ModelInterface { ...@@ -89,7 +95,7 @@ public class CompoEntryParticipant implements ModelInterface {
public CompoEntryParticipant() { public CompoEntryParticipant() {
} }
public CompoEntryParticipant(Integer entryParticipationsId) { public CompoEntryParticipant(EventPk entryParticipationsId) {
this.id = entryParticipationsId; this.id = entryParticipationsId;
} }
......
...@@ -9,11 +9,10 @@ import java.util.List; ...@@ -9,11 +9,10 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -38,12 +37,10 @@ import javax.persistence.Version; ...@@ -38,12 +37,10 @@ import javax.persistence.Version;
@NamedQuery(name = "Discount.findByActive", query = "SELECT d FROM Discount d WHERE d.active = :active"), @NamedQuery(name = "Discount.findByActive", query = "SELECT d FROM Discount d WHERE d.active = :active"),
@NamedQuery(name = "Discount.findByMaxNum", query = "SELECT d FROM Discount d WHERE d.maxNum = :maxNum"), @NamedQuery(name = "Discount.findByMaxNum", query = "SELECT d FROM Discount d WHERE d.maxNum = :maxNum"),
@NamedQuery(name = "Discount.findByPerUser", query = "SELECT d FROM Discount d WHERE d.perUser = :perUser") }) @NamedQuery(name = "Discount.findByPerUser", query = "SELECT d FROM Discount d WHERE d.perUser = :perUser") })
public class Discount implements ModelInterface { public class Discount implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "discounts_id", nullable = false)
private Integer id;
@Column(name = "percentage", nullable = false, columnDefinition = "integer default 0") @Column(name = "percentage", nullable = false, columnDefinition = "integer default 0")
private int percentage = 0; private int percentage = 0;
...@@ -73,11 +70,18 @@ public class Discount implements ModelInterface { ...@@ -73,11 +70,18 @@ public class Discount implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "discount") @OneToMany(cascade = CascadeType.ALL, mappedBy = "discount")
private List<DiscountInstance> discountInstances; private List<DiscountInstance> discountInstances;
@JoinColumn(name = "roles_id", referencedColumnName = "roles_id", nullable = false) @JoinColumns({
@JoinColumn(name = "roles_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="roles_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Role role; private Role role;
@JoinColumns({
@JoinColumn(name = "products_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="products_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
@JoinColumn(name = "products_id", referencedColumnName = "products_id", nullable = false) })
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Product product; private Product product;
...@@ -88,21 +92,21 @@ public class Discount implements ModelInterface { ...@@ -88,21 +92,21 @@ public class Discount implements ModelInterface {
public Discount() { public Discount() {
} }
public Discount(Integer discountsId) { public Discount(EventPk discountsId) {
this.id = discountsId; this.id = discountsId;
} }
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
public Discount(Integer discountsId, int percentage, int amountMin, public Discount(EventPk discountsId, int percentage, int amountMin,
int amountMax, boolean active, int maxNum, int perUser) { int amountMax, boolean active, int maxNum, int perUser) {
this.id = discountsId; this.id = discountsId;
this.setPercentage(percentage); this.setPercentage(percentage);
......
...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model; ...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -26,23 +25,27 @@ import javax.persistence.Version; ...@@ -26,23 +25,27 @@ import javax.persistence.Version;
@Entity @Entity
@Table(name = "discount_instances") @Table(name = "discount_instances")
@NamedQueries( { @NamedQuery(name = "DiscountInstance.findAll", query = "SELECT d FROM DiscountInstance d") }) @NamedQueries( { @NamedQuery(name = "DiscountInstance.findAll", query = "SELECT d FROM DiscountInstance d") })
public class DiscountInstance implements ModelInterface { public class DiscountInstance implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "discounts_instances_id", nullable = false)
private Integer id;
@Column(name = "create_time", nullable = false) @Column(name = "create_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar createTime = Calendar.getInstance(); private Calendar createTime = Calendar.getInstance();
@JoinColumn(name = "account_events_id", referencedColumnName = "account_events_id") @JoinColumns({
@JoinColumn(name = "account_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="account_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne @ManyToOne
private AccountEvent accountEvent; private AccountEvent accountEvent;
@JoinColumn(name = "discounts_id", referencedColumnName = "discounts_id", nullable = false) @JoinColumns({
@JoinColumn(name = "discounts_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="discounts_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Discount discount; private Discount discount;
...@@ -57,7 +60,7 @@ public class DiscountInstance implements ModelInterface { ...@@ -57,7 +60,7 @@ public class DiscountInstance implements ModelInterface {
public DiscountInstance() { public DiscountInstance() {
} }
public DiscountInstance(Integer discountsInstancesId) { public DiscountInstance(EventPk discountsInstancesId) {
this.id = discountsInstancesId; this.id = discountsInstancesId;
} }
...@@ -117,7 +120,7 @@ public class DiscountInstance implements ModelInterface { ...@@ -117,7 +120,7 @@ public class DiscountInstance implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -126,7 +129,7 @@ public class DiscountInstance implements ModelInterface { ...@@ -126,7 +129,7 @@ public class DiscountInstance implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -14,6 +14,7 @@ import javax.persistence.GeneratedValue; ...@@ -14,6 +14,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -36,7 +37,7 @@ import javax.persistence.Version; ...@@ -36,7 +37,7 @@ import javax.persistence.Version;
@NamedQuery(name = "Event.findByEndTime", query = "SELECT e FROM Event e WHERE e.endTime = :endTime"), @NamedQuery(name = "Event.findByEndTime", query = "SELECT e FROM Event e WHERE e.endTime = :endTime"),
@NamedQuery(name = "Event.findByName", query = "SELECT e FROM Event e WHERE e.name = :name"), @NamedQuery(name = "Event.findByName", query = "SELECT e FROM Event e WHERE e.name = :name"),
@NamedQuery(name = "Event.findByReferer", query = "SELECT e FROM Event e WHERE e.referer = :referer") }) @NamedQuery(name = "Event.findByReferer", query = "SELECT e FROM Event e WHERE e.referer = :referer") })
public class Event implements ModelInterface { public class Event implements ModelInterface<Integer> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
...@@ -58,15 +59,23 @@ public class Event implements ModelInterface { ...@@ -58,15 +59,23 @@ public class Event implements ModelInterface {
@Column(name = "referer") @Column(name = "referer")
private String referer; private String referer;
@JoinColumn(name = "event_settings_id", referencedColumnName = "event_settings_id", nullable = false) @JoinColumns({
@JoinColumn(name = "event_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="event_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private EventSettings settings; private EventSettings settings;
@JoinColumns({
@JoinColumn(name = "event_status_id", referencedColumnName = "event_status_id", nullable = false) @JoinColumn(name = "event_status_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="event_status_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private EventStatus status; private EventStatus status;
@JoinColumn(name = "default_role", referencedColumnName = "roles_id") @JoinColumns({
@JoinColumn(name = "default_role_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="default_role_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@OneToOne @OneToOne
private Role defaultRole; private Role defaultRole;
......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.model;
import java.io.Serializable;
/**
*
* @author tuukka
*/
public interface EventChildInterface extends ModelInterface<EventPk>, Serializable {
public EventPk getId();
public void setId(EventPk id);
public int getJpaVersionField();
public void setJpaVersionField(int jpaVersionField);
}
...@@ -8,10 +8,8 @@ import java.util.List; ...@@ -8,10 +8,8 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
...@@ -30,13 +28,11 @@ import javax.persistence.Version; ...@@ -30,13 +28,11 @@ import javax.persistence.Version;
@NamedQuery(name = "EventMap.findAll", query = "SELECT e FROM EventMap e"), @NamedQuery(name = "EventMap.findAll", query = "SELECT e FROM EventMap e"),
@NamedQuery(name = "EventMap.findByName", query = "SELECT e FROM EventMap e WHERE e.name = :name") }) @NamedQuery(name = "EventMap.findByName", query = "SELECT e FROM EventMap e WHERE e.name = :name") })
public class EventMap implements ModelInterface { public class EventMap implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "maps_id", nullable = false)
private Integer id;
@Lob @Lob
@Column(name = "map_data") @Column(name = "map_data")
...@@ -61,7 +57,7 @@ public class EventMap implements ModelInterface { ...@@ -61,7 +57,7 @@ public class EventMap implements ModelInterface {
public EventMap() { public EventMap() {
} }
public EventMap(Integer mapsId) { public EventMap(EventPk mapsId) {
this.id = mapsId; this.id = mapsId;
} }
...@@ -128,7 +124,7 @@ public class EventMap implements ModelInterface { ...@@ -128,7 +124,7 @@ public class EventMap implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -137,7 +133,7 @@ public class EventMap implements ModelInterface { ...@@ -137,7 +133,7 @@ public class EventMap implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
package fi.insomnia.bortal.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* Entity implementation class for Entity: EntityPK
*
*/
@Embeddable
public class EventPk implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "entity_id", nullable = false)
private Integer id;
@Column(name = "events_pk_id", nullable = false, updatable = false)
private Integer eventId;
private static final long serialVersionUID = 1L;
public EventPk() {
super();
}
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setEventId(Integer eventId) {
this.eventId = eventId;
}
public Integer getEventId() {
return eventId;
}
public int hashCode() {
return id.hashCode()+eventId.hashCode();
}
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj == this) return true;
if (!(obj instanceof EventPk)) return false;
EventPk pk = (EventPk) obj;
return pk.id == this.id && pk.eventId == this.eventId;
}
}
...@@ -8,10 +8,8 @@ import java.util.List; ...@@ -8,10 +8,8 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -27,15 +25,13 @@ import javax.persistence.Version; ...@@ -27,15 +25,13 @@ import javax.persistence.Version;
@Table(name = "event_settings") @Table(name = "event_settings")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "EventSettings.findAll", query = "SELECT e FROM EventSettings e"), @NamedQuery(name = "EventSettings.findAll", query = "SELECT e FROM EventSettings e"),
@NamedQuery(name = "EventSettings.findByOrganisation", query = "SELECT e FROM EventSettings e WHERE e.organisation = :organisation"), @NamedQuery(name = "EventSettings.findByBundleCountry", query = "SELECT e FROM EventSettings e WHERE e.bundleCountry = :bundleCountry")
@NamedQuery(name = "EventSettings.findByBundleCountry", query = "SELECT e FROM EventSettings e WHERE e.bundleCountry = :bundlecountry") }) })
public class EventSettings implements ModelInterface { public class EventSettings implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "event_settings_id", nullable = false)
private Integer id;
@Column(name = "organisation") @Column(name = "organisation")
private String organisation; private String organisation;
...@@ -58,7 +54,7 @@ public class EventSettings implements ModelInterface { ...@@ -58,7 +54,7 @@ public class EventSettings implements ModelInterface {
public EventSettings() { public EventSettings() {
} }
public EventSettings(Integer eventSettingsId) { public EventSettings(EventPk eventSettingsId) {
this.id = eventSettingsId; this.id = eventSettingsId;
} }
...@@ -101,7 +97,7 @@ public class EventSettings implements ModelInterface { ...@@ -101,7 +97,7 @@ public class EventSettings implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -110,7 +106,7 @@ public class EventSettings implements ModelInterface { ...@@ -110,7 +106,7 @@ public class EventSettings implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -8,10 +8,8 @@ import java.util.List; ...@@ -8,10 +8,8 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
...@@ -28,14 +26,12 @@ import javax.persistence.Version; ...@@ -28,14 +26,12 @@ import javax.persistence.Version;
@NamedQuery(name = "EventStatus.findAll", query = "SELECT e FROM EventStatus e"), @NamedQuery(name = "EventStatus.findAll", query = "SELECT e FROM EventStatus e"),
@NamedQuery(name = "EventStatus.findByStatusName", query = "SELECT e FROM EventStatus e WHERE e.statusName = :statusName") }) @NamedQuery(name = "EventStatus.findByStatusName", query = "SELECT e FROM EventStatus e WHERE e.statusName = :statusName") })
public class EventStatus implements ModelInterface { public class EventStatus implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "event_status_id", nullable = false)
private Integer id;
@Column(name = "status_name", nullable = false) @Column(name = "status_name", nullable = false)
private String statusName; private String statusName;
...@@ -50,11 +46,11 @@ public class EventStatus implements ModelInterface { ...@@ -50,11 +46,11 @@ public class EventStatus implements ModelInterface {
public EventStatus() { public EventStatus() {
} }
public EventStatus(Integer eventStatusId) { public EventStatus(EventPk eventStatusId) {
this.id = eventStatusId; this.id = eventStatusId;
} }
public EventStatus(Integer eventStatusId, String statusName) { public EventStatus(EventPk eventStatusId, String statusName) {
this.id = eventStatusId; this.id = eventStatusId;
this.statusName = statusName; this.statusName = statusName;
} }
...@@ -106,7 +102,7 @@ public class EventStatus implements ModelInterface { ...@@ -106,7 +102,7 @@ public class EventStatus implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -115,7 +111,7 @@ public class EventStatus implements ModelInterface { ...@@ -115,7 +111,7 @@ public class EventStatus implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -8,10 +8,8 @@ import java.util.Calendar; ...@@ -8,10 +8,8 @@ import java.util.Calendar;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -33,13 +31,11 @@ import javax.persistence.Version; ...@@ -33,13 +31,11 @@ import javax.persistence.Version;
@NamedQuery(name = "FoodWave.findByDescription", query = "SELECT f FROM FoodWave f WHERE f.description = :description"), @NamedQuery(name = "FoodWave.findByDescription", query = "SELECT f FROM FoodWave f WHERE f.description = :description"),
@NamedQuery(name = "FoodWave.findByTime", query = "SELECT f FROM FoodWave f WHERE f.time = :time"), @NamedQuery(name = "FoodWave.findByTime", query = "SELECT f FROM FoodWave f WHERE f.time = :time"),
@NamedQuery(name = "FoodWave.findByClosed", query = "SELECT f FROM FoodWave f WHERE f.closed = :closed") }) @NamedQuery(name = "FoodWave.findByClosed", query = "SELECT f FROM FoodWave f WHERE f.closed = :closed") })
public class FoodWave implements ModelInterface { public class FoodWave implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "food_waves_id", nullable = false)
private Integer id;
@Column(name = "wave_name", nullable = false) @Column(name = "wave_name", nullable = false)
private String name; private String name;
...@@ -65,11 +61,11 @@ public class FoodWave implements ModelInterface { ...@@ -65,11 +61,11 @@ public class FoodWave implements ModelInterface {
public FoodWave() { public FoodWave() {
} }
public FoodWave(Integer foodWavesId) { public FoodWave(EventPk foodWavesId) {
this.id = foodWavesId; this.id = foodWavesId;
} }
public FoodWave(Integer foodWavesId, String waveName, boolean waveClosed) { public FoodWave(EventPk foodWavesId, String waveName, boolean waveClosed) {
this.id = foodWavesId; this.id = foodWavesId;
this.name = waveName; this.name = waveName;
this.closed = waveClosed; this.closed = waveClosed;
...@@ -147,7 +143,7 @@ public class FoodWave implements ModelInterface { ...@@ -147,7 +143,7 @@ public class FoodWave implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -156,7 +152,7 @@ public class FoodWave implements ModelInterface { ...@@ -156,7 +152,7 @@ public class FoodWave implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -7,10 +7,8 @@ package fi.insomnia.bortal.model; ...@@ -7,10 +7,8 @@ package fi.insomnia.bortal.model;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -28,13 +26,11 @@ import javax.persistence.Version; ...@@ -28,13 +26,11 @@ import javax.persistence.Version;
@NamedQuery(name = "FoodWaveTemplate.findByName", query = "SELECT f FROM FoodWaveTemplate f WHERE f.name = :name"), @NamedQuery(name = "FoodWaveTemplate.findByName", query = "SELECT f FROM FoodWaveTemplate f WHERE f.name = :name"),
@NamedQuery(name = "FoodWaveTemplate.findByDescription", query = "SELECT f FROM FoodWaveTemplate f WHERE f.description = :description") }) @NamedQuery(name = "FoodWaveTemplate.findByDescription", query = "SELECT f FROM FoodWaveTemplate f WHERE f.description = :description") })
public class FoodWaveTemplate implements ModelInterface { public class FoodWaveTemplate implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "food_wave_templates_id", nullable = false)
private Integer id;
@Column(name = "template_name", nullable = false) @Column(name = "template_name", nullable = false)
private String name; private String name;
...@@ -53,11 +49,11 @@ public class FoodWaveTemplate implements ModelInterface { ...@@ -53,11 +49,11 @@ public class FoodWaveTemplate implements ModelInterface {
public FoodWaveTemplate() { public FoodWaveTemplate() {
} }
public FoodWaveTemplate(Integer foodWaveTemplatesId) { public FoodWaveTemplate(EventPk foodWaveTemplatesId) {
this.id = foodWaveTemplatesId; this.id = foodWaveTemplatesId;
} }
public FoodWaveTemplate(Integer foodWaveTemplatesId, String templateName) { public FoodWaveTemplate(EventPk foodWaveTemplatesId, String templateName) {
this.id = foodWaveTemplatesId; this.id = foodWaveTemplatesId;
this.name = templateName; this.name = templateName;
} }
...@@ -124,7 +120,7 @@ public class FoodWaveTemplate implements ModelInterface { ...@@ -124,7 +120,7 @@ public class FoodWaveTemplate implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -133,7 +129,7 @@ public class FoodWaveTemplate implements ModelInterface { ...@@ -133,7 +129,7 @@ public class FoodWaveTemplate implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model; ...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -34,13 +33,11 @@ import javax.persistence.Version; ...@@ -34,13 +33,11 @@ import javax.persistence.Version;
@NamedQuery(name = "GroupMembership.findByInviteAccepted", query = "SELECT g FROM GroupMembership g WHERE g.inviteAccepted = :inviteAccepted"), @NamedQuery(name = "GroupMembership.findByInviteAccepted", query = "SELECT g FROM GroupMembership g WHERE g.inviteAccepted = :inviteAccepted"),
@NamedQuery(name = "GroupMembership.findByInviteEmail", query = "SELECT g FROM GroupMembership g WHERE g.inviteEmail = :inviteEmail"), @NamedQuery(name = "GroupMembership.findByInviteEmail", query = "SELECT g FROM GroupMembership g WHERE g.inviteEmail = :inviteEmail"),
@NamedQuery(name = "GroupMembership.findByInviteName", query = "SELECT g FROM GroupMembership g WHERE g.inviteName = :inviteName") }) @NamedQuery(name = "GroupMembership.findByInviteName", query = "SELECT g FROM GroupMembership g WHERE g.inviteName = :inviteName") })
public class GroupMembership implements ModelInterface { public class GroupMembership implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "group_memberships_id", nullable = false)
private Integer id;
@Column(name = "invite_accepted") @Column(name = "invite_accepted")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
...@@ -52,15 +49,27 @@ public class GroupMembership implements ModelInterface { ...@@ -52,15 +49,27 @@ public class GroupMembership implements ModelInterface {
@Column(name = "invite_name") @Column(name = "invite_name")
private String inviteName; private String inviteName;
@JoinColumn(name = "groups_id", referencedColumnName = "groups_id", nullable = false) @JoinColumns({
@JoinColumn(name = "groups_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="groups_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private PlaceGroup placeGroup; private PlaceGroup placeGroup;
@JoinColumn(name = "place_reservation", referencedColumnName = "places_id", nullable = false) @JoinColumns({
@JoinColumn(name = "place_reservation_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="place_reservation_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@OneToOne(optional = false) @OneToOne(optional = false)
private Place placeReservation; private Place placeReservation;
@JoinColumn(name = "users_id", referencedColumnName = "users_id") @JoinColumns({
@JoinColumn(name = "users_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="users_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne @ManyToOne
private User user; private User user;
...@@ -77,7 +86,7 @@ public class GroupMembership implements ModelInterface { ...@@ -77,7 +86,7 @@ public class GroupMembership implements ModelInterface {
public GroupMembership() { public GroupMembership() {
} }
public GroupMembership(Integer groupMembershipsId) { public GroupMembership(EventPk groupMembershipsId) {
this.id = groupMembershipsId; this.id = groupMembershipsId;
} }
...@@ -160,7 +169,7 @@ public class GroupMembership implements ModelInterface { ...@@ -160,7 +169,7 @@ public class GroupMembership implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -169,7 +178,7 @@ public class GroupMembership implements ModelInterface { ...@@ -169,7 +178,7 @@ public class GroupMembership implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -7,10 +7,8 @@ package fi.insomnia.bortal.model; ...@@ -7,10 +7,8 @@ package fi.insomnia.bortal.model;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
...@@ -26,13 +24,11 @@ import javax.persistence.Version; ...@@ -26,13 +24,11 @@ import javax.persistence.Version;
@NamedQuery(name = "Location.findAll", query = "SELECT l FROM Location l"), @NamedQuery(name = "Location.findAll", query = "SELECT l FROM Location l"),
@NamedQuery(name = "Location.findByLocationName", query = "SELECT l FROM Location l WHERE l.name = :name") }) @NamedQuery(name = "Location.findByLocationName", query = "SELECT l FROM Location l WHERE l.name = :name") })
public class Location implements ModelInterface { public class Location implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "locations_id", nullable = false)
private Integer id;
@Column(name = "location_name", nullable = false) @Column(name = "location_name", nullable = false)
private String name; private String name;
...@@ -50,11 +46,11 @@ public class Location implements ModelInterface { ...@@ -50,11 +46,11 @@ public class Location implements ModelInterface {
public Location() { public Location() {
} }
public Location(Integer locationsId) { public Location(EventPk locationsId) {
this.id = locationsId; this.id = locationsId;
} }
public Location(Integer locationsId, String locationName) { public Location(EventPk locationsId, String locationName) {
this.id = locationsId; this.id = locationsId;
this.name = locationName; this.name = locationName;
} }
...@@ -114,7 +110,7 @@ public class Location implements ModelInterface { ...@@ -114,7 +110,7 @@ public class Location implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -123,7 +119,7 @@ public class Location implements ModelInterface { ...@@ -123,7 +119,7 @@ public class Location implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -9,11 +9,10 @@ import static javax.persistence.TemporalType.TIMESTAMP; ...@@ -9,11 +9,10 @@ import static javax.persistence.TemporalType.TIMESTAMP;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -31,14 +30,12 @@ import javax.persistence.Version; ...@@ -31,14 +30,12 @@ import javax.persistence.Version;
@NamedQuery(name = "LogEntry.findAll", query = "SELECT l FROM LogEntry l"), @NamedQuery(name = "LogEntry.findAll", query = "SELECT l FROM LogEntry l"),
@NamedQuery(name = "LogEntry.findByTime", query = "SELECT l FROM LogEntry l WHERE l.time = :time"), @NamedQuery(name = "LogEntry.findByTime", query = "SELECT l FROM LogEntry l WHERE l.time = :time"),
@NamedQuery(name = "LogEntry.findByDescription", query = "SELECT l FROM LogEntry l WHERE l.description = :description") }) @NamedQuery(name = "LogEntry.findByDescription", query = "SELECT l FROM LogEntry l WHERE l.description = :description") })
public class LogEntry implements ModelInterface { public class LogEntry implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "event_log_id", nullable = false)
private Integer id;
@Column(name = "event_time", nullable = false) @Column(name = "event_time", nullable = false)
@Temporal(TIMESTAMP) @Temporal(TIMESTAMP)
...@@ -48,7 +45,10 @@ public class LogEntry implements ModelInterface { ...@@ -48,7 +45,10 @@ public class LogEntry implements ModelInterface {
@Column(name = "event_description") @Column(name = "event_description")
private String description; private String description;
@JoinColumn(name = "event_log_types_id", referencedColumnName = "event_log_types_id", nullable = false) @JoinColumns({
@JoinColumn(name = "event_log_type_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="event_log_event_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private LogEntryType type; private LogEntryType type;
...@@ -63,11 +63,11 @@ public class LogEntry implements ModelInterface { ...@@ -63,11 +63,11 @@ public class LogEntry implements ModelInterface {
public LogEntry() { public LogEntry() {
} }
public LogEntry(Integer eventLogId) { public LogEntry(EventPk eventLogId) {
this.id = eventLogId; this.id = eventLogId;
} }
public LogEntry(Integer eventLogId, Calendar eventTime) { public LogEntry(EventPk eventLogId, Calendar eventTime) {
this.id = eventLogId; this.id = eventLogId;
this.time = eventTime; this.time = eventTime;
} }
...@@ -135,7 +135,7 @@ public class LogEntry implements ModelInterface { ...@@ -135,7 +135,7 @@ public class LogEntry implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -144,7 +144,7 @@ public class LogEntry implements ModelInterface { ...@@ -144,7 +144,7 @@ public class LogEntry implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -8,10 +8,8 @@ import java.util.List; ...@@ -8,10 +8,8 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -28,14 +26,12 @@ import javax.persistence.Version; ...@@ -28,14 +26,12 @@ import javax.persistence.Version;
@NamedQuery(name = "LogEntryType.findAll", query = "SELECT l FROM LogEntryType l"), @NamedQuery(name = "LogEntryType.findAll", query = "SELECT l FROM LogEntryType l"),
@NamedQuery(name = "LogEntryType.findByDescription", query = "SELECT l FROM LogEntryType l WHERE l.description = :description") }) @NamedQuery(name = "LogEntryType.findByDescription", query = "SELECT l FROM LogEntryType l WHERE l.description = :description") })
public class LogEntryType implements ModelInterface { public class LogEntryType implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "event_log_types_id", nullable = false)
private Integer id;
@Lob @Lob
@Column(name = "event_type_description", nullable = false) @Column(name = "event_type_description", nullable = false)
...@@ -51,11 +47,11 @@ public class LogEntryType implements ModelInterface { ...@@ -51,11 +47,11 @@ public class LogEntryType implements ModelInterface {
public LogEntryType() { public LogEntryType() {
} }
public LogEntryType(Integer eventLogTypesId) { public LogEntryType(EventPk eventLogTypesId) {
this.id = eventLogTypesId; this.id = eventLogTypesId;
} }
public LogEntryType(Integer eventLogTypesId, String eventTypeDescription) { public LogEntryType(EventPk eventLogTypesId, String eventTypeDescription) {
this.id = eventLogTypesId; this.id = eventLogTypesId;
this.description = eventTypeDescription; this.description = eventTypeDescription;
} }
...@@ -107,7 +103,7 @@ public class LogEntryType implements ModelInterface { ...@@ -107,7 +103,7 @@ public class LogEntryType implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -116,7 +112,7 @@ public class LogEntryType implements ModelInterface { ...@@ -116,7 +112,7 @@ public class LogEntryType implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.model; package fi.insomnia.bortal.model;
import java.io.Serializable; public interface ModelInterface<T> {
public T getId();
/**
*
* @author tuukka
*/
public interface ModelInterface extends Serializable {
public Integer getId();
public void setId(Integer id); public void setId(T id);
public int getJpaVersionField(); public int getJpaVersionField();
public void setJpaVersionField(int jpaVersionField); public void setJpaVersionField(int jpaVersionField);
} }
...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model; ...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -36,13 +35,11 @@ import javax.persistence.Version; ...@@ -36,13 +35,11 @@ import javax.persistence.Version;
@NamedQuery(name = "News.findByPublish", query = "SELECT n FROM News n WHERE n.publish = :publish"), @NamedQuery(name = "News.findByPublish", query = "SELECT n FROM News n WHERE n.publish = :publish"),
@NamedQuery(name = "News.findByExpire", query = "SELECT n FROM News n WHERE n.expire = :expire"), @NamedQuery(name = "News.findByExpire", query = "SELECT n FROM News n WHERE n.expire = :expire"),
@NamedQuery(name = "News.findByPriority", query = "SELECT n FROM News n WHERE n.priority = :priority") }) @NamedQuery(name = "News.findByPriority", query = "SELECT n FROM News n WHERE n.priority = :priority") })
public class News implements ModelInterface { public class News implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "news_id", nullable = false)
private Integer id;
@Column(name = "title", nullable = false) @Column(name = "title", nullable = false)
private String title; private String title;
...@@ -66,7 +63,12 @@ public class News implements ModelInterface { ...@@ -66,7 +63,12 @@ public class News implements ModelInterface {
@Column(name = "priority", nullable = false) @Column(name = "priority", nullable = false)
private int priority; private int priority;
@JoinColumn(name = "news_groups_id", referencedColumnName = "news_groups_id", nullable = false)
@JoinColumns({
@JoinColumn(name = "news_groups_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="news_groups_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private NewsGroup group; private NewsGroup group;
...@@ -77,11 +79,11 @@ public class News implements ModelInterface { ...@@ -77,11 +79,11 @@ public class News implements ModelInterface {
public News() { public News() {
} }
public News(Integer newsId) { public News(EventPk newsId) {
this.id = newsId; this.id = newsId;
} }
public News(Integer newsId, String title, int priority) { public News(EventPk newsId, String title, int priority) {
this.id = newsId; this.id = newsId;
this.title = title; this.title = title;
this.priority = priority; this.priority = priority;
...@@ -174,7 +176,7 @@ public class News implements ModelInterface { ...@@ -174,7 +176,7 @@ public class News implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -183,7 +185,7 @@ public class News implements ModelInterface { ...@@ -183,7 +185,7 @@ public class News implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -8,12 +8,8 @@ import java.util.List; ...@@ -8,12 +8,8 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -33,14 +29,12 @@ import javax.persistence.Version; ...@@ -33,14 +29,12 @@ import javax.persistence.Version;
@NamedQuery(name = "NewsGroup.findByName", query = "SELECT n FROM NewsGroup n WHERE n.name = :name"), @NamedQuery(name = "NewsGroup.findByName", query = "SELECT n FROM NewsGroup n WHERE n.name = :name"),
@NamedQuery(name = "NewsGroup.findByDescription", query = "SELECT n FROM NewsGroup n WHERE n.description = :description"), @NamedQuery(name = "NewsGroup.findByDescription", query = "SELECT n FROM NewsGroup n WHERE n.description = :description"),
@NamedQuery(name = "NewsGroup.findByPriority", query = "SELECT n FROM NewsGroup n WHERE n.priority = :priority") }) @NamedQuery(name = "NewsGroup.findByPriority", query = "SELECT n FROM NewsGroup n WHERE n.priority = :priority") })
public class NewsGroup implements ModelInterface { public class NewsGroup implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "news_groups_id", nullable = false)
private Integer id;
@Column(name = "group_name", nullable = false) @Column(name = "group_name", nullable = false)
private String name; private String name;
...@@ -53,7 +47,14 @@ public class NewsGroup implements ModelInterface { ...@@ -53,7 +47,14 @@ public class NewsGroup implements ModelInterface {
private int priority; private int priority;
@ManyToMany @ManyToMany
@JoinTable(name = "roles_news_groups", joinColumns = @JoinColumn(name = "news_groups_id", referencedColumnName = "news_groups_id"), inverseJoinColumns = @JoinColumn(name = "roles_id", referencedColumnName = "roles_id")) /* @JoinTable(name = "roles_news_groups", joinColumns = {
@JoinColumn(name = "entity_id", referencedColumnName = "news_groups_id"),
@JoinColumn(name = "events_pk_id", referencedColumnName = "news_groups_event_id")
}, inverseJoinColumns ={
@JoinColumn(name = "entity_id", referencedColumnName = "roles_id"),
@JoinColumn(name = "events_pk_id", referencedColumnName = "roles_event_id")}
)
}*/
private List<Role> roles; private List<Role> roles;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "group") @OneToMany(cascade = CascadeType.ALL, mappedBy = "group")
...@@ -66,11 +67,11 @@ public class NewsGroup implements ModelInterface { ...@@ -66,11 +67,11 @@ public class NewsGroup implements ModelInterface {
public NewsGroup() { public NewsGroup() {
} }
public NewsGroup(Integer newsGroupsId) { public NewsGroup(EventPk newsGroupsId) {
this.id = newsGroupsId; this.id = newsGroupsId;
} }
public NewsGroup(Integer newsGroupsId, String groupName, int priority) { public NewsGroup(EventPk newsGroupsId, String groupName, int priority) {
this.id = newsGroupsId; this.id = newsGroupsId;
this.name = groupName; this.name = groupName;
this.priority = priority; this.priority = priority;
...@@ -140,7 +141,7 @@ public class NewsGroup implements ModelInterface { ...@@ -140,7 +141,7 @@ public class NewsGroup implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -149,7 +150,7 @@ public class NewsGroup implements ModelInterface { ...@@ -149,7 +150,7 @@ public class NewsGroup implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -5,11 +5,10 @@ ...@@ -5,11 +5,10 @@
package fi.insomnia.bortal.model; package fi.insomnia.bortal.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -26,19 +25,16 @@ import javax.persistence.Version; ...@@ -26,19 +25,16 @@ import javax.persistence.Version;
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "Place.findAll", query = "SELECT p FROM Place p"), @NamedQuery(name = "Place.findAll", query = "SELECT p FROM Place p"),
@NamedQuery(name = "Place.findByDescription", query = "SELECT p FROM Place p WHERE p.description = :description"), @NamedQuery(name = "Place.findByDescription", query = "SELECT p FROM Place p WHERE p.description = :description"),
@NamedQuery(name = "Place.findByName", query = "SELECT p FROM Place p WHERE p.name = :name"), @NamedQuery(name = "Place.findByName", query = "SELECT p FROM Place p WHERE p.name = :name"),
@NamedQuery(name = "Place.findByMapX", query = "SELECT p FROM Place p WHERE p.mapX = :mapX"), @NamedQuery(name = "Place.findByMapX", query = "SELECT p FROM Place p WHERE p.mapX = :mapX"),
@NamedQuery(name = "Place.findByMapY", query = "SELECT p FROM Place p WHERE p.mapY = :mapY"), @NamedQuery(name = "Place.findByMapY", query = "SELECT p FROM Place p WHERE p.mapY = :mapY"),
@NamedQuery(name = "Place.findByDetails", query = "SELECT p FROM Place p WHERE p.details = :details"), @NamedQuery(name = "Place.findByDetails", query = "SELECT p FROM Place p WHERE p.details = :details"),
@NamedQuery(name = "Place.findByCode", query = "SELECT p FROM Place p WHERE p.code = :code") }) @NamedQuery(name = "Place.findByCode", query = "SELECT p FROM Place p WHERE p.code = :code") })
public class Place implements ModelInterface { public class Place implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "places_id", nullable = false)
private Integer id;
@Lob @Lob
@Column(name = "place_description") @Column(name = "place_description")
private String description; private String description;
...@@ -60,18 +56,29 @@ public class Place implements ModelInterface { ...@@ -60,18 +56,29 @@ public class Place implements ModelInterface {
/** /**
* Which group has bought the place * Which group has bought the place
*/ */
@JoinColumn(name = "groups_id", referencedColumnName = "groups_id") @JoinColumns({
@JoinColumn(name = "groups_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="groups_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne @ManyToOne
private PlaceGroup placeGroup; private PlaceGroup placeGroup;
@JoinColumn(name = "maps_id", referencedColumnName = "maps_id", nullable = false) @JoinColumns({
@JoinColumn(name = "maps_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="maps_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private EventMap map; private EventMap map;
/** /**
* Which ticket type is this place sold as * Which ticket type is this place sold as
*/ */
@JoinColumn(name = "products_id", referencedColumnName = "products_id", nullable = false) @JoinColumns({
@JoinColumn(name = "products_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="products_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Product product; private Product product;
...@@ -90,7 +97,7 @@ public class Place implements ModelInterface { ...@@ -90,7 +97,7 @@ public class Place implements ModelInterface {
public Place() { public Place() {
} }
public Place(Integer placesId) { public Place(EventPk placesId) {
this.id = placesId; this.id = placesId;
} }
...@@ -205,7 +212,7 @@ public class Place implements ModelInterface { ...@@ -205,7 +212,7 @@ public class Place implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -214,7 +221,7 @@ public class Place implements ModelInterface { ...@@ -214,7 +221,7 @@ public class Place implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -9,10 +9,8 @@ import java.util.List; ...@@ -9,10 +9,8 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
...@@ -37,13 +35,11 @@ import javax.persistence.Version; ...@@ -37,13 +35,11 @@ import javax.persistence.Version;
@NamedQuery(name = "PlaceGroup.findByName", query = "SELECT p FROM PlaceGroup p WHERE p.name = :name"), @NamedQuery(name = "PlaceGroup.findByName", query = "SELECT p FROM PlaceGroup p WHERE p.name = :name"),
@NamedQuery(name = "PlaceGroup.findByActive", query = "SELECT p FROM PlaceGroup p WHERE p.active = :active"), @NamedQuery(name = "PlaceGroup.findByActive", query = "SELECT p FROM PlaceGroup p WHERE p.active = :active"),
@NamedQuery(name = "PlaceGroup.findByDetails", query = "SELECT p FROM PlaceGroup p WHERE p.details = :details") }) @NamedQuery(name = "PlaceGroup.findByDetails", query = "SELECT p FROM PlaceGroup p WHERE p.details = :details") })
public class PlaceGroup implements ModelInterface { public class PlaceGroup implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "groups_id", nullable = false)
private Integer id;
@Column(name = "group_created", nullable = false) @Column(name = "group_created", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
...@@ -83,11 +79,11 @@ public class PlaceGroup implements ModelInterface { ...@@ -83,11 +79,11 @@ public class PlaceGroup implements ModelInterface {
public PlaceGroup() { public PlaceGroup() {
} }
public PlaceGroup(Integer groupsId) { public PlaceGroup(EventPk groupsId) {
this.id = groupsId; this.id = groupsId;
} }
public PlaceGroup(Integer groupsId, Calendar groupCreated, Calendar groupEdited, public PlaceGroup(EventPk groupsId, Calendar groupCreated, Calendar groupEdited,
boolean groupActive) { boolean groupActive) {
this.id = groupsId; this.id = groupsId;
this.created = groupCreated; this.created = groupCreated;
...@@ -198,7 +194,7 @@ public class PlaceGroup implements ModelInterface { ...@@ -198,7 +194,7 @@ public class PlaceGroup implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -207,7 +203,7 @@ public class PlaceGroup implements ModelInterface { ...@@ -207,7 +203,7 @@ public class PlaceGroup implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -10,11 +10,10 @@ import java.util.List; ...@@ -10,11 +10,10 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -36,12 +35,10 @@ import javax.persistence.Version; ...@@ -36,12 +35,10 @@ import javax.persistence.Version;
@NamedQuery(name = "PrintedCard.findByBarcode", query = "SELECT p FROM PrintedCard p WHERE p.barcode = :barcode"), @NamedQuery(name = "PrintedCard.findByBarcode", query = "SELECT p FROM PrintedCard p WHERE p.barcode = :barcode"),
@NamedQuery(name = "PrintedCard.findByEnabled", query = "SELECT p FROM PrintedCard p WHERE p.enabled = :enabled"), @NamedQuery(name = "PrintedCard.findByEnabled", query = "SELECT p FROM PrintedCard p WHERE p.enabled = :enabled"),
@NamedQuery(name = "PrintedCard.findByRfidUid", query = "SELECT p FROM PrintedCard p WHERE p.rfidUid = :rfidUid") }) @NamedQuery(name = "PrintedCard.findByRfidUid", query = "SELECT p FROM PrintedCard p WHERE p.rfidUid = :rfidUid") })
public class PrintedCard implements ModelInterface { public class PrintedCard implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "printed_cards_id", nullable = false)
private Integer id;
@Column(name = "print_time", nullable = false) @Column(name = "print_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
...@@ -59,7 +56,10 @@ public class PrintedCard implements ModelInterface { ...@@ -59,7 +56,10 @@ public class PrintedCard implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard") @OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard")
private List<ReaderEvent> readerEvents; private List<ReaderEvent> readerEvents;
@JoinColumn(name = "current_location", referencedColumnName = "locations_id") @JoinColumns({
@JoinColumn(name = "current_location_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="current_location_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne @ManyToOne
private Location currentLocation; private Location currentLocation;
...@@ -67,7 +67,10 @@ public class PrintedCard implements ModelInterface { ...@@ -67,7 +67,10 @@ public class PrintedCard implements ModelInterface {
@ManyToOne(optional = false) @ManyToOne(optional = false)
private User user; private User user;
@JoinColumn(name = "card_templates_id", referencedColumnName = "card_templates_id", nullable = false) @JoinColumns({
@JoinColumn(name = "card_template_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="card_template_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private CardTemplate template; private CardTemplate template;
...@@ -79,20 +82,20 @@ public class PrintedCard implements ModelInterface { ...@@ -79,20 +82,20 @@ public class PrintedCard implements ModelInterface {
} }
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
public PrintedCard(Integer printedCardsId) { public PrintedCard(EventPk printedCardsId) {
this.id = printedCardsId; this.id = printedCardsId;
} }
public PrintedCard(Integer printedCardsId, Calendar printTime, public PrintedCard(EventPk printedCardsId, Calendar printTime,
boolean cardEnabled) { boolean cardEnabled) {
this.id = printedCardsId; this.id = printedCardsId;
this.printTime = printTime; this.printTime = printTime;
......
...@@ -9,12 +9,8 @@ import java.util.List; ...@@ -9,12 +9,8 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -27,21 +23,19 @@ import javax.persistence.Version; ...@@ -27,21 +23,19 @@ import javax.persistence.Version;
*/ */
@Entity @Entity
@Table(name = "products") @Table(name = "products")
@NamedQueries( { @NamedQueries({
@NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p"), @NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p"),
@NamedQuery(name = "Product.findByProductName", query = "SELECT p FROM Product p WHERE p.name = :name"), @NamedQuery(name = "Product.findByProductName", query = "SELECT p FROM Product p WHERE p.name = :name"),
@NamedQuery(name = "Product.findByPrice", query = "SELECT p FROM Product p WHERE p.price = :price"), @NamedQuery(name = "Product.findByPrice", query = "SELECT p FROM Product p WHERE p.price = :price"),
@NamedQuery(name = "Product.findBySort", query = "SELECT p FROM Product p WHERE p.sort = :sort"), @NamedQuery(name = "Product.findBySort", query = "SELECT p FROM Product p WHERE p.sort = :sort"),
@NamedQuery(name = "Product.findByBarcode", query = "SELECT p FROM Product p WHERE p.barcode = :barcode") }) @NamedQuery(name = "Product.findByBarcode", query = "SELECT p FROM Product p WHERE p.barcode = :barcode") })
public class Product implements ModelInterface { public class Product implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "products_id", nullable = false)
private Integer id;
@Column(name = "product_name") @Column(name = "product_name")
private String name; private String name;
...@@ -61,7 +55,13 @@ public class Product implements ModelInterface { ...@@ -61,7 +55,13 @@ public class Product implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product") @OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
private List<AccountEvent> accountEvents; private List<AccountEvent> accountEvents;
@JoinTable(name = "food_wave_templates_products", joinColumns = { @JoinColumn(name = "products_id", referencedColumnName = "products_id") }, inverseJoinColumns = { @JoinColumn(name = "food_wave_templates_id", referencedColumnName = "food_wave_templates_id") }) /* @JoinTable(name = "food_wave_templates_products", joinColumns =
{ @JoinColumn(name = "entity_id", referencedColumnName = "products_id"),
@JoinColumn(name = "events_pk_id", referencedColumnName = "product_event_id") },
inverseJoinColumns =
{ @JoinColumn(name = "entity_id", referencedColumnName = "food_wave_templates_id"),
@JoinColumn(name = "events_pk_id", referencedColumnName = "food_wave_templates_event_id") })
*/
@ManyToMany @ManyToMany
private List<FoodWaveTemplate> foodWaveTemplate; private List<FoodWaveTemplate> foodWaveTemplate;
...@@ -75,11 +75,11 @@ public class Product implements ModelInterface { ...@@ -75,11 +75,11 @@ public class Product implements ModelInterface {
public Product() { public Product() {
} }
public Product(Integer productsId) { public Product(EventPk productsId) {
this.id = productsId; this.id = productsId;
} }
public Product(Integer productsId, BigInteger price, int sort) { public Product(EventPk productsId, BigInteger price, int sort) {
this.id = productsId; this.id = productsId;
this.price = price; this.price = price;
this.sort = sort; this.sort = sort;
...@@ -179,7 +179,7 @@ public class Product implements ModelInterface { ...@@ -179,7 +179,7 @@ public class Product implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -188,7 +188,7 @@ public class Product implements ModelInterface { ...@@ -188,7 +188,7 @@ public class Product implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -8,11 +8,10 @@ import java.util.List; ...@@ -8,11 +8,10 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -31,14 +30,12 @@ import javax.persistence.Version; ...@@ -31,14 +30,12 @@ import javax.persistence.Version;
@NamedQuery(name = "Reader.findByIdentification", query = "SELECT r FROM Reader r WHERE r.identification = :identification"), @NamedQuery(name = "Reader.findByIdentification", query = "SELECT r FROM Reader r WHERE r.identification = :identification"),
@NamedQuery(name = "Reader.findByDescription", query = "SELECT r FROM Reader r WHERE r.description = :description") }) @NamedQuery(name = "Reader.findByDescription", query = "SELECT r FROM Reader r WHERE r.description = :description") })
public class Reader implements ModelInterface { public class Reader implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "readers_id", nullable = false)
private Integer id;
@Column(name = "reader_ident") @Column(name = "reader_ident")
private String identification; private String identification;
...@@ -49,8 +46,9 @@ public class Reader implements ModelInterface { ...@@ -49,8 +46,9 @@ public class Reader implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "reader") @OneToMany(cascade = CascadeType.ALL, mappedBy = "reader")
private List<ReaderEvent> events; private List<ReaderEvent> events;
@JoinColumns({
@JoinColumn(name = "locations_id", referencedColumnName = "locations_id") @JoinColumn(name = "location_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "location_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne @ManyToOne
private Location location; private Location location;
...@@ -60,7 +58,9 @@ public class Reader implements ModelInterface { ...@@ -60,7 +58,9 @@ public class Reader implements ModelInterface {
@ManyToOne @ManyToOne
@JoinColumn(name = "maps_id", referencedColumnName = "maps_id") @JoinColumns({
@JoinColumn(name = "maps_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "maps_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) })
private EventMap eventMap; private EventMap eventMap;
...@@ -76,7 +76,7 @@ public class Reader implements ModelInterface { ...@@ -76,7 +76,7 @@ public class Reader implements ModelInterface {
public Reader() { public Reader() {
} }
public Reader(Integer readersId) { public Reader(EventPk readersId) {
this.id = readersId; this.id = readersId;
} }
...@@ -143,7 +143,7 @@ public class Reader implements ModelInterface { ...@@ -143,7 +143,7 @@ public class Reader implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -152,7 +152,7 @@ public class Reader implements ModelInterface { ...@@ -152,7 +152,7 @@ public class Reader implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model; ...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -30,14 +29,12 @@ import javax.persistence.Version; ...@@ -30,14 +29,12 @@ import javax.persistence.Version;
@NamedQuery(name = "ReaderEvent.findByTime", query = "SELECT r FROM ReaderEvent r WHERE r.time = :time"), @NamedQuery(name = "ReaderEvent.findByTime", query = "SELECT r FROM ReaderEvent r WHERE r.time = :time"),
@NamedQuery(name = "ReaderEvent.findByValue", query = "SELECT r FROM ReaderEvent r WHERE r.value = :value") }) @NamedQuery(name = "ReaderEvent.findByValue", query = "SELECT r FROM ReaderEvent r WHERE r.value = :value") })
public class ReaderEvent implements ModelInterface { public class ReaderEvent implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "reader_events_id", nullable = false)
private Integer id;
@Column(name = "event_time", nullable = false) @Column(name = "event_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
...@@ -46,11 +43,17 @@ public class ReaderEvent implements ModelInterface { ...@@ -46,11 +43,17 @@ public class ReaderEvent implements ModelInterface {
@Column(name = "value") @Column(name = "value")
private String value; private String value;
@JoinColumn(name = "printed_cards_id", referencedColumnName = "printed_cards_id", nullable = false) @JoinColumns({
@JoinColumn(name = "printed_cards_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="printed_cards_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private PrintedCard printedCard; private PrintedCard printedCard;
@JoinColumn(name = "readers_id", referencedColumnName = "readers_id", nullable = false) @JoinColumns({
@JoinColumn(name = "readers_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="readers_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Reader reader; private Reader reader;
...@@ -61,11 +64,11 @@ public class ReaderEvent implements ModelInterface { ...@@ -61,11 +64,11 @@ public class ReaderEvent implements ModelInterface {
public ReaderEvent() { public ReaderEvent() {
} }
public ReaderEvent(Integer readerEventsId) { public ReaderEvent(EventPk readerEventsId) {
this.id = readerEventsId; this.id = readerEventsId;
} }
public ReaderEvent(Integer readerEventsId, Calendar eventTime) { public ReaderEvent(EventPk readerEventsId, Calendar eventTime) {
this.id = readerEventsId; this.id = readerEventsId;
this.time = eventTime; this.time = eventTime;
} }
...@@ -133,7 +136,7 @@ public class ReaderEvent implements ModelInterface { ...@@ -133,7 +136,7 @@ public class ReaderEvent implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -142,7 +145,7 @@ public class ReaderEvent implements ModelInterface { ...@@ -142,7 +145,7 @@ public class ReaderEvent implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -8,11 +8,10 @@ import java.util.List; ...@@ -8,11 +8,10 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
...@@ -27,27 +26,27 @@ import javax.persistence.Version; ...@@ -27,27 +26,27 @@ import javax.persistence.Version;
*/ */
@Entity @Entity
@Table(name = "roles") @Table(name = "roles")
@NamedQueries( { @NamedQueries({
@NamedQuery(name = "Role.findAll", query = "SELECT r FROM Role r"), @NamedQuery(name = "Role.findAll", query = "SELECT r FROM Role r"),
@NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.name = :name") }) @NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.name = :name") })
public class Role implements ModelInterface { public class Role implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "roles_id", nullable = false)
private Integer id;
@Column(name = "role_name", nullable = false) @Column(name = "role_name", nullable = false)
private String name; private String name;
@ManyToMany(cascade = CascadeType.ALL) @ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "role_memberships", joinColumns = @JoinColumn(name = "roles_id", referencedColumnName = "roles_id"), inverseJoinColumns = @JoinColumn(name = "users_id", referencedColumnName = "users_id")) @JoinTable(name = "role_memberships", joinColumns = {@JoinColumn(name = "roles_id", referencedColumnName = "entity_id"),@JoinColumn(name = "roles_event_id", referencedColumnName = "events_pk_id")}, inverseJoinColumns = @JoinColumn(name = "users_id", referencedColumnName = "users_id"))
private List<User> users; private List<User> users;
@ManyToMany @ManyToMany
@JoinTable(name = "role_parents", joinColumns = @JoinColumn(name = "parent", referencedColumnName = "roles_id"), inverseJoinColumns = @JoinColumn(name = "roles_id", referencedColumnName = "roles_id")) @JoinColumns({
@JoinColumn(name = "role_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "role_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) })
private List<Role> children; private List<Role> children;
@ManyToMany(mappedBy = "children") @ManyToMany(mappedBy = "children")
...@@ -56,7 +55,9 @@ public class Role implements ModelInterface { ...@@ -56,7 +55,9 @@ public class Role implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "role") @OneToMany(cascade = CascadeType.ALL, mappedBy = "role")
private List<RoleRight> roleRights; private List<RoleRight> roleRights;
@JoinColumn(name = "card_templates_id", referencedColumnName = "card_templates_id") @JoinColumns({
@JoinColumn(name = "card_template_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "card_template_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne @ManyToOne
private CardTemplate cardTemplate; private CardTemplate cardTemplate;
...@@ -74,15 +75,14 @@ public class Role implements ModelInterface { ...@@ -74,15 +75,14 @@ public class Role implements ModelInterface {
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
public Role() { public Role() {
} }
public Role(Integer rolesId) { public Role(EventPk rolesId) {
this.id = rolesId; this.id = rolesId;
} }
public Role(Integer rolesId, String roleName) { public Role(EventPk rolesId, String roleName) {
this.id = rolesId; this.id = rolesId;
this.name = roleName; this.name = roleName;
} }
...@@ -150,7 +150,7 @@ public class Role implements ModelInterface { ...@@ -150,7 +150,7 @@ public class Role implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -159,7 +159,7 @@ public class Role implements ModelInterface { ...@@ -159,7 +159,7 @@ public class Role implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
...@@ -211,4 +211,12 @@ public class Role implements ModelInterface { ...@@ -211,4 +211,12 @@ public class Role implements ModelInterface {
public List<Role> getChildren() { public List<Role> getChildren() {
return children; return children;
} }
public void setNewsGroups(List<NewsGroup> newsGroups) {
this.newsGroups = newsGroups;
}
public List<NewsGroup> getNewsGroups() {
return newsGroups;
}
} }
...@@ -5,11 +5,10 @@ ...@@ -5,11 +5,10 @@
package fi.insomnia.bortal.model; package fi.insomnia.bortal.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -35,13 +34,11 @@ import javax.persistence.Version; ...@@ -35,13 +34,11 @@ import javax.persistence.Version;
* @ NamedQuery ( name = "RoleRight.findByExecute" , query = * @ NamedQuery ( name = "RoleRight.findByExecute" , query =
* "SELECT r FROM RoleRight r WHERE r.execute = :execute" ) * "SELECT r FROM RoleRight r WHERE r.execute = :execute" )
*/}) */})
public class RoleRight implements ModelInterface { public class RoleRight implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "role_rights_id", nullable = false)
private Integer id;
@Column(name = "read_permission", nullable = false) @Column(name = "read_permission", nullable = false)
private boolean read; private boolean read;
...@@ -56,7 +53,9 @@ public class RoleRight implements ModelInterface { ...@@ -56,7 +53,9 @@ public class RoleRight implements ModelInterface {
@ManyToOne @ManyToOne
private AccessRight accessRight; private AccessRight accessRight;
@JoinColumn(name = "roles_id", referencedColumnName = "roles_id", nullable = false) @JoinColumns({
@JoinColumn(name = "role_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "role_event_id", referencedColumnName = "events_pk_id", nullable = false) })
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Role role; private Role role;
...@@ -67,11 +66,11 @@ public class RoleRight implements ModelInterface { ...@@ -67,11 +66,11 @@ public class RoleRight implements ModelInterface {
public RoleRight() { public RoleRight() {
} }
public RoleRight(Integer roleRights) { public RoleRight(EventPk roleRights) {
this.id = roleRights; this.id = roleRights;
} }
public RoleRight(Integer roleRights, boolean read, boolean write) { public RoleRight(EventPk roleRights, boolean read, boolean write) {
this.id = roleRights; this.id = roleRights;
this.read = read; this.read = read;
this.write = write; this.write = write;
...@@ -140,7 +139,7 @@ public class RoleRight implements ModelInterface { ...@@ -140,7 +139,7 @@ public class RoleRight implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -149,7 +148,7 @@ public class RoleRight implements ModelInterface { ...@@ -149,7 +148,7 @@ public class RoleRight implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -13,7 +13,6 @@ import javax.persistence.Entity; ...@@ -13,7 +13,6 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -46,7 +45,7 @@ import javax.persistence.Version; ...@@ -46,7 +45,7 @@ import javax.persistence.Version;
@NamedQuery(name = "User.findByPhone", query = "SELECT u FROM User u WHERE u.phone = :phone"), @NamedQuery(name = "User.findByPhone", query = "SELECT u FROM User u WHERE u.phone = :phone"),
@NamedQuery(name = "User.findByFemale", query = "SELECT u FROM User u WHERE u.female = :female"), @NamedQuery(name = "User.findByFemale", query = "SELECT u FROM User u WHERE u.female = :female"),
@NamedQuery(name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") }) @NamedQuery(name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") })
public class User implements ModelInterface { public class User implements ModelInterface<Integer>{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -63,15 +62,12 @@ public class User implements ModelInterface { ...@@ -63,15 +62,12 @@ public class User implements ModelInterface {
private boolean active; private boolean active;
@Column(name = "password") @Column(name = "password")
@Lob
private String password; private String password;
@Column(name = "lastname") @Column(name = "lastname")
@Lob
private String lastname; private String lastname;
@Column(name = "firstnames") @Column(name = "firstnames")
@Lob
private String firstnames; private String firstnames;
@Column(name = "birthday") @Column(name = "birthday")
...@@ -79,43 +75,33 @@ public class User implements ModelInterface { ...@@ -79,43 +75,33 @@ public class User implements ModelInterface {
private Calendar birthday; private Calendar birthday;
@Column(name = "nick") @Column(name = "nick")
@Lob
private String nick; private String nick;
@Column(name = "email") @Column(name = "email")
@Lob
private String email; private String email;
@Column(name = "address") @Column(name = "address")
@Lob
private String address; private String address;
@Column(name = "zip") @Column(name = "zip")
@Lob
private String zip; private String zip;
@Column(name = "postal_code") @Column(name = "postal_code")
@Lob
private String postalCode; private String postalCode;
@Column(name = "town") @Column(name = "town")
@Lob
private String town; private String town;
@Column(name = "phone") @Column(name = "phone")
@Lob
private String phone; private String phone;
@Column(name = "female") @Column(name = "female")
@Lob
private Boolean female; private Boolean female;
@Column(name = "login") @Column(name = "login")
@Lob
private String login; private String login;
@Column(name = "confirm_hash") @Column(name = "confirm_hash")
@Lob
private String confirmHash; private String confirmHash;
@Column(name = "confirm_time") @Column(name = "confirm_time")
......
...@@ -5,10 +5,8 @@ ...@@ -5,10 +5,8 @@
package fi.insomnia.bortal.model; package fi.insomnia.bortal.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
...@@ -28,14 +26,12 @@ import javax.persistence.Version; ...@@ -28,14 +26,12 @@ import javax.persistence.Version;
@NamedQuery(name = "UserImage.findByName", query = "SELECT u FROM UserImage u WHERE u.name = :name"), @NamedQuery(name = "UserImage.findByName", query = "SELECT u FROM UserImage u WHERE u.name = :name"),
@NamedQuery(name = "UserImage.findByDescription", query = "SELECT u FROM UserImage u WHERE u.description = :description"), @NamedQuery(name = "UserImage.findByDescription", query = "SELECT u FROM UserImage u WHERE u.description = :description"),
@NamedQuery(name = "UserImage.findByMimeType", query = "SELECT u FROM UserImage u WHERE u.mimeType = :mimeType") }) @NamedQuery(name = "UserImage.findByMimeType", query = "SELECT u FROM UserImage u WHERE u.mimeType = :mimeType") })
public class UserImage implements ModelInterface { public class UserImage implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "user_images_id", nullable = false)
private Integer id;
@Column(name = "name") @Column(name = "name")
private String name; private String name;
...@@ -62,7 +58,7 @@ public class UserImage implements ModelInterface { ...@@ -62,7 +58,7 @@ public class UserImage implements ModelInterface {
public UserImage() { public UserImage() {
} }
public UserImage(Integer userImagesId) { public UserImage(EventPk userImagesId) {
this.id = userImagesId; this.id = userImagesId;
} }
...@@ -129,7 +125,7 @@ public class UserImage implements ModelInterface { ...@@ -129,7 +125,7 @@ public class UserImage implements ModelInterface {
* @return the id * @return the id
*/ */
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
...@@ -138,7 +134,7 @@ public class UserImage implements ModelInterface { ...@@ -138,7 +134,7 @@ public class UserImage implements ModelInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(Integer id) { public void setId(EventPk id) {
this.id = id; this.id = id;
} }
......
...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model; ...@@ -7,11 +7,10 @@ package fi.insomnia.bortal.model;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
...@@ -32,21 +31,23 @@ import javax.persistence.Version; ...@@ -32,21 +31,23 @@ import javax.persistence.Version;
@NamedQuery(name = "Vote.findByScore", query = "SELECT v FROM Vote v WHERE v.score = :score"), @NamedQuery(name = "Vote.findByScore", query = "SELECT v FROM Vote v WHERE v.score = :score"),
@NamedQuery(name = "Vote.findByTime", query = "SELECT v FROM Vote v WHERE v.time = :time") }) @NamedQuery(name = "Vote.findByTime", query = "SELECT v FROM Vote v WHERE v.time = :time") })
public class Vote implements ModelInterface { public class Vote implements EventChildInterface{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @EmbeddedId
@GeneratedValue(strategy = GenerationType.IDENTITY) private EventPk id;
@Column(name = "votes_id", nullable = false)
private Integer id;
@Column(name = "score") @Column(name = "score")
private Integer score; private Integer score;
@Column(name = "vote_time", nullable = false) @Column(name = "vote_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar time; private Calendar time;
@JoinColumn(name = "entries_id", referencedColumnName = "entries_id", nullable = false) @JoinColumns({
@JoinColumn(name = "entries_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "entries_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false) @ManyToOne(optional = false)
private CompoEntry compoEntry; private CompoEntry compoEntry;
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false) @JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private User voter; private User voter;
...@@ -57,22 +58,22 @@ public class Vote implements ModelInterface { ...@@ -57,22 +58,22 @@ public class Vote implements ModelInterface {
public Vote() { public Vote() {
} }
public Vote(Integer votesId) { public Vote(EventPk votesId) {
this.id = votesId; this.id = votesId;
} }
public Vote(Integer votesId, Calendar voteTime) { public Vote(EventPk votesId, Calendar voteTime) {
this.id = votesId; this.id = votesId;
this.time = voteTime; this.time = voteTime;
} }
@Override @Override
public Integer getId() { public EventPk getId() {
return id; return id;
} }
@Override @Override
public void setId(Integer votesId) { public void setId(EventPk votesId) {
this.id = votesId; this.id = votesId;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!