OneToMany & ManyToOne mapping JPA / Hibernate

Can you move the relationship to a related object like this

@ManyToOne()
@JoinColumn(name="role_id", referencedColumnName = "role_id", insertable = false, updatable = false)    
private UserRole userRole;

and same do for userRole

@OneToMany(targetEntity=User.class, mappedBy="userRole",cascade=CascadeType.ALL, fetch = FetchType.LAZY)    
private List<User> user = new ArrayList<>();

Update

The jar file seems to be corrupted. Try removing the content from the .m2\repository and mvn clean install

OR

Right-click your project, select Maven, Update Project, check on Force Update of Snapshots/Releases.


Just a hint, check your entity classes and ensure you have included @Entity annotation just before the class declaration statement.

@Entity
public class MyEntityClass{
 //code
}

Then on any other entity class that uses MyEntityClass above under the @ManyToMany or @OneToMany relationship add the following.

@OneToMany(mappedBy="mappingItem", cascade=CascadeType.ALL, orphanRemoval=true)
@JsonIgnore
private List<MyEntityClass> myEntityClassItemList;

This approach worked for me some how, may be it might help.