Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ec613581
authored
Oct 31, 2010
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Plain Diff
Pikkumuutoksia entityihin
2 parents
8474ad8c
bc2ff294
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
5 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PollBean.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Poll.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollQuestion.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PossibleAnswer.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PollBean.java
View file @
ec61358
...
...
@@ -9,9 +9,11 @@ import javax.ejb.Stateless;
import
fi.insomnia.bortal.facade.PollAnswerFacade
;
import
fi.insomnia.bortal.facade.PollFacade
;
import
fi.insomnia.bortal.facade.PossibleAnswerFacade
;
import
fi.insomnia.bortal.model.Poll
;
import
fi.insomnia.bortal.model.PollAnswer
;
import
fi.insomnia.bortal.model.PollQuestion
;
import
fi.insomnia.bortal.model.PossibleAnswer
;
/**
* Session Bean implementation class PollBean
...
...
@@ -32,6 +34,9 @@ public class PollBean implements PollBeanLocal {
@EJB
private
UserBean
userBean
;
@EJB
private
PossibleAnswerFacade
possibleAnswerFacade
;
/**
* Default constructor.
*/
...
...
@@ -85,4 +90,10 @@ public class PollBean implements PollBeanLocal {
return
false
;
}
@Override
public
PossibleAnswer
findPossibleAnwerById
(
int
id
)
{
PossibleAnswer
ans
=
possibleAnswerFacade
.
find
(
eventBean
.
getCurrentEvent
().
getId
(),
new
Integer
(
id
));
return
ans
;
}
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Poll.java
View file @
ec61358
...
...
@@ -7,6 +7,7 @@ import java.util.ArrayList;
import
java.util.Calendar
;
import
java.util.List
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.FetchType
;
...
...
@@ -43,7 +44,7 @@ public class Poll extends GenericEventChild implements Serializable {
@Column
(
name
=
"description"
,
nullable
=
true
)
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
>();
public
Poll
()
{
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollQuestion.java
View file @
ec61358
...
...
@@ -3,6 +3,7 @@ package fi.insomnia.bortal.model;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.JoinColumn
;
...
...
@@ -37,7 +38,7 @@ public class PollQuestion extends GenericEventChild {
@ManyToOne
private
Poll
poll
;
@OneToMany
(
mappedBy
=
"question"
)
@OneToMany
(
mappedBy
=
"question"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
PossibleAnswer
>
answers
=
new
ArrayList
<
PossibleAnswer
>();
@Lob
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PossibleAnswer.java
View file @
ec61358
...
...
@@ -2,6 +2,7 @@ package fi.insomnia.bortal.model;
import
java.util.List
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.JoinColumn
;
...
...
@@ -33,8 +34,8 @@ public class PossibleAnswer extends GenericEventChild {
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@ManyToOne
private
PollQuestion
question
;
@OneToMany
(
mappedBy
=
"choice"
)
@OneToMany
(
mappedBy
=
"choice"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
PollAnswer
>
answers
;
public
String
getAnswer
()
{
...
...
@@ -84,6 +85,5 @@ public class PossibleAnswer extends GenericEventChild {
public
void
setAnswers
(
List
<
PollAnswer
>
answers
)
{
this
.
answers
=
answers
;
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment