Hey guys....i am searching for some days for the problem...Maybe one of you can find the error
DATABASE SHEMA:
https://www.file-upload.net/download-12530779/2017-06-0214_25_00-MySQLWorkbench.png.html
Entities:
package com.example.demo; import java.io.Serializable; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.Table; @SuppressWarnings("unused") @Entity @Table(name = "user") public class user implements Serializable { private static final long serialVersionUID = 1L; // @GeneratedValue @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @Column(name = "username") private String username; @Column(name = "password") private String password; @Column(name = "email") private String email; @ManyToMany @JoinTable(name="chat", joinColumns={@JoinColumn(name="userid1", referencedColumnName="id")}, inverseJoinColumns={@JoinColumn(name="messageid", referencedColumnName="id")}) private Set<message> messages; public Set<message> getMessages() { return messages; } public void setMessages(Set<message> messages) { this.messages = messages; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } private String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public user() { } }
package com.example.demo; import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; @Entity @Table(name = "message") public class message { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private int id; @Column(name = "message") private String message; @ManyToMany(mappedBy = "messages") private Set<user> user; public Set<user> getUser() { return user; } public void setUser(Set<user> user) { this.user = user; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public message() { } }