From 500140a26eebb5a18944380712e1ccc6a7733db5 Mon Sep 17 00:00:00 2001 From: Aslak Knutsen Date: Fri, 20 Sep 2013 01:01:05 +0200 Subject: [PATCH] Allow null Session.start date When a Session is first created it does not have a start date. A start date is first set when the presentation is 'activated'. Remove instance variable Session in MemberRegistration. MemberRegistration is a Session bean and belong to a pool. If this session instance were to be used it would be random which instance the given method would be operating on. fixes #3 --- src/main/java/com/onslyde/domain/Session.java | 2 +- src/main/java/com/onslyde/service/MemberRegistration.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/onslyde/domain/Session.java b/src/main/java/com/onslyde/domain/Session.java index 9720a9a..f231cd8 100644 --- a/src/main/java/com/onslyde/domain/Session.java +++ b/src/main/java/com/onslyde/domain/Session.java @@ -92,7 +92,7 @@ public void setSessionCode(String sessionCode) { } @Temporal(TemporalType.TIMESTAMP) - @Column(name = "start", nullable = false, length = 19) + @Column(name = "start", nullable = true, length = 19) public Date getStart() { return this.start; } diff --git a/src/main/java/com/onslyde/service/MemberRegistration.java b/src/main/java/com/onslyde/service/MemberRegistration.java index 11da005..b9a05a8 100644 --- a/src/main/java/com/onslyde/service/MemberRegistration.java +++ b/src/main/java/com/onslyde/service/MemberRegistration.java @@ -43,13 +43,11 @@ public class MemberRegistration { @Inject private MemberRepository repository; - private Session currentSession; - public int register(User user) throws Exception { log.info("Registering " + user.getFullName()); user.setCreated(new Date()); em.persist(user); - currentSession = new Session(); + Session currentSession = new Session(); currentSession.setSessionCode("beta"); currentSession.setSessionName("beta"); currentSession.setUser(user); @@ -63,7 +61,7 @@ public int createPresentation(String email, String token, String presName) throw log.info("Create presentation for: " + email); User user = repository.findByEmail(email); if(token.equals(String.valueOf(user.getCreated().getTime()))){ - currentSession = new Session(); + Session currentSession = new Session(); currentSession.setSessionCode("beta"); currentSession.setSessionName(presName); currentSession.setUser(user);