Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- @Table(name="suggestion")
- @JsonIgnoreProperties({"suggestionLikes"})
- public class Suggestion {
- public Suggestion() {
- // TODO Auto-generated constructor stub
- }
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="suggestion_id")
- private Integer suggestionId;
- @Column(name="description")
- private String description;
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name="suggestion_by")
- private UserProfile user;
- //getters and setters
- }
- @Entity
- @Table(name = "user_master")
- @JsonIgnoreProperties({"suggestions", "suggestionLikes"})
- public class UserProfile implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 7400472171878370L;
- public UserProfile() {
- }
- @Id
- @NotNull
- @Column(name = "username", length = 55)
- private String userName;
- @NotNull
- @Column(name = "password")
- private String password;
- @OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
- private Set<Suggestion> suggestions;
- //getters and setters
- }
- @Override
- @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
- public List<Suggestion> getAllSuggestion() {
- ArrayList<Suggestion> suggestions = (ArrayList<Suggestion>)
- suggestionRespository.findAll();
- return suggestions;
- }
- @Repository
- public interface SuggestionRespository extends JpaRepository<Suggestion,
- Integer> {
- public List<Suggestion> findAll();
- }
- @EnableTransactionManagement
- @SpringBootApplication
- public class AngularSpringbootApplication {
- public static void main(String[] args) {
- SpringApplication.run(AngularSpringbootApplication.class, args);
- }
- }
- spring.datasource.url=jdbc:mysql://localhost:3306/plan_trip
- spring.datasource.username=root
- spring.datasource.password=root
- spring.jpa.properties.hibernate.dialect =
- org.hibernate.dialect.MySQL5InnoDBDialect
- spring.jpa.hibernate.ddl-auto = update
- spring.jackson.serialization.fail-on-empty-beans=false
Add Comment
Please, Sign In to add comment