From dd28897006349e530e8dacb7bd1af37de0bd9a1a Mon Sep 17 00:00:00 2001 From: NicholasWolak Date: Mon, 16 Aug 2021 14:49:11 -0400 Subject: [PATCH 1/4] implemented domains and repos --- .../domain/Option.java | 42 ++++++++++++++ .../domain/Poll.java | 55 +++++++++++++++++++ .../domain/Vote.java | 41 ++++++++++++++ .../repositories/OptionRepository.java | 10 ++++ .../repositories/PollRepository.java | 11 ++++ .../repositories/VoteRepository.java | 9 +++ 6 files changed, 168 insertions(+) create mode 100644 src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java create mode 100644 src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java create mode 100644 src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java create mode 100644 src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java create mode 100644 src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java create mode 100644 src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java diff --git a/src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java b/src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java new file mode 100644 index 0000000..0fa978f --- /dev/null +++ b/src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java @@ -0,0 +1,42 @@ +package io.zipcoder.tc_spring_poll_application.domain; + + +import org.springframework.boot.autoconfigure.AutoConfigureOrder; + +import javax.persistence.*; + +@Entity +public class Option { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "OPTION_ID") + private Long id; + + @Column(name = "OPTION_VALUE") + private String value; + + public Option() { + } + + public Option(Long id, String value) { + this.id = id; + this.value = value; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java b/src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java new file mode 100644 index 0000000..11d675e --- /dev/null +++ b/src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java @@ -0,0 +1,55 @@ +package io.zipcoder.tc_spring_poll_application.domain; + + +import javax.persistence.*; +import java.util.Set; + +@Entity +public class Poll { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "POLL_ID") + private Long id; + + @Column(name = "QUESTION") + private String question; + + @OneToMany(cascade = CascadeType.ALL) + @JoinColumn(name = "POLL_ID") + @OrderBy + private Set