Commit ec613581 by Tuomas Riihimäki

Pikkumuutoksia entityihin

2 parents 8474ad8c bc2ff294
...@@ -9,9 +9,11 @@ import javax.ejb.Stateless; ...@@ -9,9 +9,11 @@ import javax.ejb.Stateless;
import fi.insomnia.bortal.facade.PollAnswerFacade; import fi.insomnia.bortal.facade.PollAnswerFacade;
import fi.insomnia.bortal.facade.PollFacade; import fi.insomnia.bortal.facade.PollFacade;
import fi.insomnia.bortal.facade.PossibleAnswerFacade;
import fi.insomnia.bortal.model.Poll; import fi.insomnia.bortal.model.Poll;
import fi.insomnia.bortal.model.PollAnswer; import fi.insomnia.bortal.model.PollAnswer;
import fi.insomnia.bortal.model.PollQuestion; import fi.insomnia.bortal.model.PollQuestion;
import fi.insomnia.bortal.model.PossibleAnswer;
/** /**
* Session Bean implementation class PollBean * Session Bean implementation class PollBean
...@@ -32,6 +34,9 @@ public class PollBean implements PollBeanLocal { ...@@ -32,6 +34,9 @@ public class PollBean implements PollBeanLocal {
@EJB @EJB
private UserBean userBean; private UserBean userBean;
@EJB
private PossibleAnswerFacade possibleAnswerFacade;
/** /**
* Default constructor. * Default constructor.
*/ */
...@@ -85,4 +90,10 @@ public class PollBean implements PollBeanLocal { ...@@ -85,4 +90,10 @@ public class PollBean implements PollBeanLocal {
return false; return false;
} }
@Override
public PossibleAnswer findPossibleAnwerById(int id) {
PossibleAnswer ans = possibleAnswerFacade.find(eventBean.getCurrentEvent().getId(), new Integer(id));
return ans;
}
} }
...@@ -7,6 +7,7 @@ import java.util.ArrayList; ...@@ -7,6 +7,7 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
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.FetchType; import javax.persistence.FetchType;
...@@ -43,7 +44,7 @@ public class Poll extends GenericEventChild implements Serializable { ...@@ -43,7 +44,7 @@ public class Poll extends GenericEventChild implements Serializable {
@Column(name = "description", nullable = true) @Column(name = "description", nullable = true)
private String description; private String description;
@OneToMany(mappedBy = "poll", fetch = FetchType.EAGER) @OneToMany(mappedBy = "poll", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<PollQuestion> questions = new ArrayList<PollQuestion>(); private List<PollQuestion> questions = new ArrayList<PollQuestion>();
public Poll() { public Poll() {
......
...@@ -3,6 +3,7 @@ package fi.insomnia.bortal.model; ...@@ -3,6 +3,7 @@ package fi.insomnia.bortal.model;
import java.util.ArrayList; import java.util.ArrayList;
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.JoinColumn; import javax.persistence.JoinColumn;
...@@ -37,7 +38,7 @@ public class PollQuestion extends GenericEventChild { ...@@ -37,7 +38,7 @@ public class PollQuestion extends GenericEventChild {
@ManyToOne @ManyToOne
private Poll poll; private Poll poll;
@OneToMany(mappedBy = "question") @OneToMany(mappedBy = "question", cascade = CascadeType.ALL)
private List<PossibleAnswer> answers = new ArrayList<PossibleAnswer>(); private List<PossibleAnswer> answers = new ArrayList<PossibleAnswer>();
@Lob @Lob
......
...@@ -2,6 +2,7 @@ package fi.insomnia.bortal.model; ...@@ -2,6 +2,7 @@ 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.JoinColumn; import javax.persistence.JoinColumn;
...@@ -34,7 +35,7 @@ public class PossibleAnswer extends GenericEventChild { ...@@ -34,7 +35,7 @@ public class PossibleAnswer extends GenericEventChild {
@ManyToOne @ManyToOne
private PollQuestion question; private PollQuestion question;
@OneToMany(mappedBy="choice") @OneToMany(mappedBy = "choice", cascade = CascadeType.ALL)
private List<PollAnswer> answers; private List<PollAnswer> answers;
public String getAnswer() { public String getAnswer() {
...@@ -85,5 +86,4 @@ public class PossibleAnswer extends GenericEventChild { ...@@ -85,5 +86,4 @@ public class PossibleAnswer extends GenericEventChild {
this.answers = answers; this.answers = answers;
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!