310 words

Find the error...JPA ENTITY HIBERNATE

#1
2017-06-02 13:24
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() {
 
}
}

 

 

josef1708
josef1708's picture
Joined on 2017-06-02
User Post #1
#2
2017-06-02 13:29

There are two issues with your post:

  1. No description of the error or the issue is provided, just code.
  2. This is the ObjectDB forum. Please use the Hibernate forum for Hibernate specific questions.
ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,762
#3
2017-06-02 13:50

 Sry.

the error is that i get in return a endless array with message in users and users in message So my annotations are not right.

 

Another forum? They all to seem to be dead or am i wrong?

 

Thx

 

josef1708
josef1708's picture
Joined on 2017-06-02
User Post #2
#4
2017-06-02 14:45

This is still not the best description of an error (obviously if you get error messages you should include them in your question). Anyway, for Hibernate questions you may try Stack Overflow.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,763

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel