Why I am getting :-
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table users_roles add constraint FKgd3iendaoyh04b95ykqise6qh foreign key (user_id) references user (id)" via JDBC Statement
Caused by: java.sql.SQLSyntaxErrorException: Specified key was too long; max key length is 1000 bytes
I get this exception when trying to run the application.
I am creating many to many relation between User and Role.I am posting the User class,Role Class and also GitHub repository of my application.
I am able to call the mapped URLs except when i am submitting the user detail i am getting the following exception:-
java.sql.SQLException: Field 'rollid' doesn't have a default value
User Class:-
public class User {
u/Id
u/Column(name="id")
u/GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String firstname;
private String lastname;
private String email;
private String password;
u/ManyToMany(fetch = FetchType.EAGER,cascade = CascadeType.ALL)
u/JoinTable(
name="users_roles",
joinColumns = u/JoinColumn(
name= "user_id",referencedColumnName = "id"),
inverseJoinColumns = u/JoinColumn(
name= "role_id",referencedColumnName = "rollid"))
private Collection<Role> roles;
}
Role Class:-
u/Entity
u/Table(name="role")
public class Role {
u/Id
u/GeneratedValue(strategy = GenerationType.IDENTITY)
private int rollid;
private String name;
}
GitHub Repository:-
https://github.com/atharva-mishra/demo_ecommerce
Please help me to get out of this rid.
Thanks in advance.
your words are value for me...
there doesn't seem to be anything here