I have been on this for serveral nights. I would like to link number in user (one user to many numbers) with user in number (many numbers to one user). I have no luck and need your knowledge. No matter what I do I always get errors with either this or that. A straight answer of what to do will do.
application.properties:
spring.jpa.hibernate.ddl-auto=validate
User entity:
@Entity
@Table(name = "user")
public class Users implements Serializable {
private static final long serialVersionUID = 2323232323L;
@Id
@Column(nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<Number> number;
Number entity:
@Entity
@Table(name = "number")
public class Number implements Serializable {
private static final long serialVersionUID = 1212121212L;
@Id
@Column(nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(cascade = CascadeType.ALL)
private Users user;
Liquibase:
<createTable tableName="user">
<column name="id" type="BIGINT(8)" autoIncrement="true">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="fk_number" type="BIGINT"/>
</createTable>
<createTable tableName="number">
<column name="id" type="BIGINT(8)" autoIncrement="true">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="user" type="BIGINT"/>
</createTable>