Commit 424fff02 by Juho Juopperi

model jpa fixes

1 parent f6dae56c
...@@ -41,7 +41,7 @@ public class AccessRight implements ModelInterface { ...@@ -41,7 +41,7 @@ public class AccessRight implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "accessRight") @OneToMany(cascade = CascadeType.ALL, mappedBy = "accessRight")
private List<NewsGroup> newsGroups; private List<NewsGroup> newsGroups;
@OneToMany(mappedBy = "id") @OneToMany(mappedBy = "accessRight")
private List<RoleRight> roleRights; private List<RoleRight> roleRights;
public Integer getId() { public Integer getId() {
......
...@@ -25,9 +25,9 @@ import javax.persistence.Version; ...@@ -25,9 +25,9 @@ import javax.persistence.Version;
@Entity @Entity
@Table(name = "card_templates") @Table(name = "card_templates")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "CardTemplate.findAll", query = "SELECT c FROM CardTemplate c"), @NamedQuery(name = "CardTemplate.findAll", query = "SELECT c FROM CardTemplate c"),
@NamedQuery(name = "CardTemplate.findById", query = "SELECT c FROM CardTemplate c WHERE c.id = :id"), @NamedQuery(name = "CardTemplate.findById", query = "SELECT c FROM CardTemplate c WHERE c.id = :id"),
@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 ModelInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
...@@ -48,7 +48,7 @@ public class CardTemplate implements ModelInterface { ...@@ -48,7 +48,7 @@ public class CardTemplate implements ModelInterface {
@OneToMany(mappedBy = "cardTemplate") @OneToMany(mappedBy = "cardTemplate")
private List<Role> roles; private List<Role> roles;
@OneToMany(mappedBy = "cardTemplate") @OneToMany(mappedBy = "template")
private List<PrintedCard> cards; private List<PrintedCard> cards;
@Version @Version
...@@ -59,95 +59,95 @@ public class CardTemplate implements ModelInterface { ...@@ -59,95 +59,95 @@ public class CardTemplate implements ModelInterface {
} }
public CardTemplate(Integer cardTemplatesId) { public CardTemplate(Integer cardTemplatesId) {
this.id = cardTemplatesId; this.id = cardTemplatesId;
} }
public CardTemplate(Integer cardTemplatesId, String templateName) { public CardTemplate(Integer cardTemplatesId, String templateName) {
this.id = cardTemplatesId; this.id = cardTemplatesId;
this.name = templateName; this.name = templateName;
} }
public byte[] getImage() { public byte[] getImage() {
return image; return image;
} }
public void setImage(byte[] templateImage) { public void setImage(byte[] templateImage) {
this.image = templateImage; this.image = templateImage;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String templateName) { public void setName(String templateName) {
this.name = templateName; this.name = templateName;
} }
public Event getEvent() { public Event getEvent() {
return event; return event;
} }
public Integer getId() { public Integer getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
public void setEvent(Event eventsId) { public void setEvent(Event eventsId) {
this.event = eventsId; this.event = eventsId;
} }
public List<Role> getRoles() { public List<Role> getRoles() {
return roles; return roles;
} }
public void setRoles(List<Role> roleList) { public void setRoles(List<Role> roleList) {
this.roles = roleList; this.roles = roleList;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 0; int hash = 0;
hash += (id != null ? id.hashCode() : 0); hash += (id != null ? id.hashCode() : 0);
return hash; return hash;
} }
@Override @Override
public boolean equals(Object object) { public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are // TODO: Warning - this method won't work in the case the id fields are
// not set // not set
if (!(object instanceof CardTemplate)) { if (!(object instanceof CardTemplate)) {
return false; return false;
} }
CardTemplate other = (CardTemplate) object; CardTemplate other = (CardTemplate) object;
if ((this.id == null && other.id != null) if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) { || (this.id != null && !this.id.equals(other.id))) {
return false; return false;
} }
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.CardTemplate[id=" + id + "]"; return "fi.insomnia.bortal.model.CardTemplate[id=" + id + "]";
} }
public void setJpaVersionField(int jpaVersionField) { public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField; this.jpaVersionField = jpaVersionField;
} }
public int getJpaVersionField() { public int getJpaVersionField() {
return jpaVersionField; return jpaVersionField;
} }
public void setCards(List<PrintedCard> cards) { public void setCards(List<PrintedCard> cards) {
this.cards = cards; this.cards = cards;
} }
public List<PrintedCard> getCards() { public List<PrintedCard> getCards() {
return cards; return cards;
} }
} }
...@@ -21,9 +21,9 @@ import javax.persistence.Version; ...@@ -21,9 +21,9 @@ import javax.persistence.Version;
@Entity @Entity
@Table(name = "locations") @Table(name = "locations")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "Location.findAll", query = "SELECT l FROM Location l"), @NamedQuery(name = "Location.findAll", query = "SELECT l FROM Location l"),
@NamedQuery(name = "Location.findById", query = "SELECT l FROM Location l WHERE l.id = :id"), @NamedQuery(name = "Location.findById", query = "SELECT l FROM Location l WHERE l.id = :id"),
@NamedQuery(name = "Location.findByLocationName", query = "SELECT l FROM Location l WHERE l.locationName = :name") }) @NamedQuery(name = "Location.findByLocationName", query = "SELECT l FROM Location l WHERE l.locationName = :name") })
public class Location implements ModelInterface { public class Location implements ModelInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -34,7 +34,7 @@ public class Location implements ModelInterface { ...@@ -34,7 +34,7 @@ public class Location implements ModelInterface {
@Column(name = "location_name", nullable = false) @Column(name = "location_name", nullable = false)
private String name; private String name;
@OneToMany(mappedBy = "id") @OneToMany(mappedBy = "location")
private List<Reader> readers; private List<Reader> readers;
@OneToMany(mappedBy = "currentLocation") @OneToMany(mappedBy = "currentLocation")
...@@ -48,70 +48,70 @@ public class Location implements ModelInterface { ...@@ -48,70 +48,70 @@ public class Location implements ModelInterface {
} }
public Location(Integer locationsId) { public Location(Integer locationsId) {
this.id = locationsId; this.id = locationsId;
} }
public Location(Integer locationsId, String locationName) { public Location(Integer locationsId, String locationName) {
this.id = locationsId; this.id = locationsId;
this.name = locationName; this.name = locationName;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String locationName) { public void setName(String locationName) {
this.name = locationName; this.name = locationName;
} }
public List<Reader> getReaders() { public List<Reader> getReaders() {
return readers; return readers;
} }
public void setReaders(List<Reader> readerList) { public void setReaders(List<Reader> readerList) {
this.readers = readerList; this.readers = readerList;
} }
public List<PrintedCard> getPrintedCardsAtLocation() { public List<PrintedCard> getPrintedCardsAtLocation() {
return printedCardsAtLocation; return printedCardsAtLocation;
} }
public void setPrintedCardsAtLocation(List<PrintedCard> printedCardList) { public void setPrintedCardsAtLocation(List<PrintedCard> printedCardList) {
this.printedCardsAtLocation = printedCardList; this.printedCardsAtLocation = printedCardList;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 0; int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0); hash += (getId() != null ? getId().hashCode() : 0);
return hash; return hash;
} }
@Override @Override
public boolean equals(Object object) { public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are // TODO: Warning - this method won't work in the case the id fields are
// not set // not set
if (!(object instanceof Location)) { if (!(object instanceof Location)) {
return false; return false;
} }
Location other = (Location) object; Location other = (Location) object;
if ((this.getId() == null && other.getId() != null) if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) { || (this.getId() != null && !this.id.equals(other.id))) {
return false; return false;
} }
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.Location[id=" + getId() + "]"; return "fi.insomnia.bortal.model.Location[id=" + getId() + "]";
} }
/** /**
* @return the id * @return the id
*/ */
public Integer getId() { public Integer getId() {
return id; return id;
} }
/** /**
...@@ -119,14 +119,14 @@ public class Location implements ModelInterface { ...@@ -119,14 +119,14 @@ public class Location implements ModelInterface {
* the id to set * the id to set
*/ */
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
/** /**
* @return the jpaVersionField * @return the jpaVersionField
*/ */
public int getJpaVersionField() { public int getJpaVersionField() {
return jpaVersionField; return jpaVersionField;
} }
/** /**
...@@ -134,6 +134,6 @@ public class Location implements ModelInterface { ...@@ -134,6 +134,6 @@ public class Location implements ModelInterface {
* the jpaVersionField to set * the jpaVersionField to set
*/ */
public void setJpaVersionField(int jpaVersionField) { public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField; this.jpaVersionField = jpaVersionField;
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!