Hallo zusammen,
seit Tagen begleitet mich ein Problem, das ich einfach nicht in den Griff bekomme.
Ich habe eine kleine klassische Test-Instanz gebaut.
Es gibt die Entities:
- Right
- Role
- User
Lösche ich direkt auf der Datenbank eine Rolle, die noch einem Nutzer zugewiesen ist, erhalte ich
SQL Error: 1451, SQLState: 23000
Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t_users_roles`, CONSTRAINT `FK_ur_roles_id` FOREIGN KEY (`roles_id`) REFERENCES `t_roles` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION)
Das ist ja auch das, was ich mit den eingefügten Constraints erreichen will.
Lösche ich jedoch mittels Hibernate, löscht er die Rolle und in den Beziehungstabellen alle Einträge, die auf die gelöschte Rolle verwiesen haben. Genau das will ich NICHT!
Kann jemand mir helfen?
Danke und Gruß,
iiMaestro
Hier der ganze Code:
Code:
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction trans = session.beginTransaction();
try {
final int id = 1;
final Object object = session.get(Role.class, id);
session.delete(object);
trans = session.beginTransaction();
trans.commit();
trans = session.beginTransaction();
Object role = session.get(Role.class, id);
assertNotNull(role);
trans.commit();
} catch (Throwable e) {
trans.rollback();
LOGGER.error(e.getMessage());
}
Code:
package models;
import static javax.persistence.GenerationType.IDENTITY;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
/**
* The persistence class for the {@link User} referring to the table
* one2one.t_users.
*
* @author Kasperbauer
*/
@Entity
@Table(name = "t_users", catalog = "test")
public class User implements Serializable {
/** Auto generated serial version ID. */
private static final long serialVersionUID = 3590436920396166477L;
/** The identifier of this user. */
private Integer id;
/** The nickname of this user. */
private String nickname;
/** The password of this user. */
private String password;
/** The first name of this user. */
private String firstName;
/** The second name of this user. */
private String secondName;
/** The status of this user. */
private String status;
/** The roles of this user. */
private Set<Role> roles = new HashSet<Role>(0);
/**
* Default constructor.
*/
public User() {
super();
}
/**
* Constructor for the not-nullable attributes.
*
* @param nickname
* The nickname of this user.
* @param password
* The password of this user.
* @param firstName
* The first name of this user.
* @param secondName
* The second name of this user.
* @param status
* The status of this user.
*/
public User(final String nickname, final String password,
final String firstName, final String secondName, final String status) {
this.nickname = nickname;
this.password = password;
this.firstName = firstName;
this.secondName = secondName;
this.status = status;
}
/**
* Constructor for all attributes.
*
* @param nickname
* The nickname of this user.
* @param password
* The password of this user.
* @param firstName
* The first name of this user.
* @param secondName
* The second name of this user.
* @param status
* The status of this user.
* @param roles
* The roles of this user.
*/
public User(final String nickname, final String password,
final String firstName, final String secondName,
final String status, final Set<Role> roles) {
this.nickname = nickname;
this.password = password;
this.firstName = firstName;
this.secondName = secondName;
this.status = status;
this.roles = roles;
}
/**
* Getter for the identifier.
*
* @return The identifier of this user.
*/
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
/**
* Setter for the identifier.
*
* @param id
* The identifier of this user.
*/
public void setId(final Integer id) {
this.id = id;
}
/**
* Getter for the nickname of this user.
*
* @return The nickname of this user.
*/
@Column(name = "nickname", nullable = false, length = 25)
public String getNickname() {
return this.nickname;
}
/**
* Setter for the nickname of this user.
*
* @param nickname
* The nickname of this user.
*/
public void setNickname(final String nickname) {
this.nickname = nickname;
}
/**
* Getter for the password of this user.
*
* @return The password of this user.
*/
@Column(name = "password", nullable = false, length = 65)
public String getPassword() {
return this.password;
}
/**
* Setter for the password of this user.
*
* @param password
* The password of this user.
*/
public void setPassword(final String password) {
this.password = password;
}
/**
* Getter for the first name of this user.
*
* @return The first name of this user.
*/
@Column(name = "first_name", nullable = false, length = 60)
public String getFirstName() {
return this.firstName;
}
/**
* Setter for the first name of this user.
*
* @param firstName
* The first name of this user.
*/
public void setFirstName(final String firstName) {
this.firstName = firstName;
}
/**
* Getter for the second name of this user.
*
* @return The second name of this user.
*/
@Column(name = "second_name", nullable = false, length = 60)
public String getSecondName() {
return this.secondName;
}
/**
* Setter for the second name of this user.
*
* @param secondName
* The second name of this user.
*/
public void setSecondName(final String secondName) {
this.secondName = secondName;
}
/**
* Getter for the status of this user.
*
* @return The status of this user.
*/
@Column(name = "status", nullable = false, length = 11)
public String getStatus() {
return this.status;
}
/**
* Setter for the status of this user.
*
* @param status
* The status of this user.
*/
public void setStatus(final String status) {
this.status = status;
}
/**
* Getter for the roles of this user.
*
* @return The roles of this user.
*/
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "t_users_roles", catalog = "test", joinColumns =
{ @JoinColumn(name = "users_id", nullable = false, updatable = false) }, inverseJoinColumns =
{ @JoinColumn(name = "roles_id", nullable = false, updatable = false) })
public Set<Role> getRoles() {
return this.roles;
}
/**
* Setter for the roles of this user.
*
* @param roles
* The roles of this user.
*/
public void setRoles(final Set<Role> roles) {
this.roles = roles;
}
/**
* The string representation of this user.
*
* @return This user as a {@link String}.
*/
@Override
public final String toString() {
StringBuffer strBuff = new StringBuffer();
strBuff.append("[User:id=");
strBuff.append(id);
strBuff.append(",nickname=");
strBuff.append(nickname);
strBuff.append(",password=");
strBuff.append(password);
strBuff.append(",firstName=");
strBuff.append(firstName);
strBuff.append(",secondName=");
strBuff.append(secondName);
strBuff.append(",status=");
strBuff.append(status);
strBuff.append("]");
return strBuff.toString();
}
}
Code:
package models;
import static javax.persistence.GenerationType.IDENTITY;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
/**
* The persistence class for the {@link Right} referring to the table
* test.t_rights.
*/
@Entity
@Table(name = "t_rights", catalog = "test")
public class Right implements Serializable {
/** Auto generated serial version ID. */
private static final long serialVersionUID = 451540231751526818L;
/** The identifier of the right. */
private Integer id;
/** The name of the right. */
private String name;
/** The additional description of the right. */
private String description;
/** The type of the right. */
private String type;
/**
* The {@link Role}s who have this right in the user management
* system.
*/
private Set<Role> roles = new HashSet<Role>(0);
/**
* Default constructor.
*/
public Right() {
super();
}
/**
* Constructor for the not-nullable attributes.
*
* @param name
* The name of the right.
* @param type
* The type of the right.
*/
public Right(final String name, final String type) {
this.name = name;
this.type = type;
}
/**
* Constructor for all attributes.
*
* @param name
* The name of the right.
* @param description
* The additional description of the right.
* @param type
* The type of the right.
* @param roles
* The {@link Role}s who have this right.
*/
public Right(final String name, final String description,
final String type, final Set<Role> roles) {
this.name = name;
this.description = description;
this.type = type;
this.roles = roles;
}
/**
* The getter for the identifier of the right.
*
* @return The id of the right.
*/
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
/**
* The setter for the identifier of the right.
*
* @param id
* The id of the right.
*/
public void setId(final Integer id) {
this.id = id;
}
/**
* The getter for the name of the right.
*
* @return The name of the right.
*/
@Column(name = "name", nullable = false, length = 25)
public String getName() {
return this.name;
}
/**
* The setter for the name of the right.
*
* @param name
* The name of the right.
*/
public void setName(final String name) {
this.name = name;
}
/**
* The getter for the additional description of the right.
*
* @return The additional description of the right.
*/
@Column(name = "description", length = 200)
public String getDescription() {
return this.description;
}
/**
* The setter for the additional description of the right.
*
* @param description
* The additional description of the right.
*/
public void setDescription(final String description) {
this.description = description;
}
/**
* The getter for the type of the right.
*
* @return The type of the right.
*/
@Column(name = "type", nullable = false, length = 10)
public String getType() {
return this.type;
}
/**
* The setter for the type of the right.
*
* @param type
* The type of the right.
*/
public void setType(final String type) {
this.type = type;
}
/**
* The getter for the {@link Role}s who have this right.
*
* @return The {@link Role}s who have this right.
*/
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "t_roles_rights", catalog = "test", joinColumns =
{ @JoinColumn(name = "rights_id", nullable = false, updatable = false) }, inverseJoinColumns =
{ @JoinColumn(name = "roles_id", nullable = false, updatable = false) })
public Set<Role> getRoles() {
return this.roles;
}
/**
* The setter for the {@link Role}s who have this right.
*
* @param roles
* The {@link Role}s who have this right.
*/
public void setRoles(final Set<Role> roles) {
this.roles = roles;
}
/**
* The string representation of this right.
*
* @return This user as a {@link String}.
*/
@Override
public final String toString() {
StringBuffer strBuff = new StringBuffer();
strBuff.append("[Right:id=");
strBuff.append(id);
strBuff.append(",name=");
strBuff.append(name);
strBuff.append(",description=");
strBuff.append(description);
strBuff.append(",type=");
strBuff.append(type);
strBuff.append("]");
return strBuff.toString();
}
}
Code:
package models;
import static javax.persistence.GenerationType.IDENTITY;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* The persistence class for the {@link Role} referring to the table
* test.t_roles.
*/
@Entity
@Table(name = "t_roles", catalog = "test")
public class Role implements Serializable {
/** Auto generated serial version ID. */
private static final long serialVersionUID = -2323667694288119044L;
/** The identifier of the role. */
private Integer id;
/** The name of the role. */
private String name;
/** The additional description of the role. */
private String description;
/** The type of the role. */
private String type;
/** The time of the last update of the role. */
private Date lastUpdated;
/**
* The {@link User}s who have this role in the one2one user management
* system.
*/
private Set<User> users = new HashSet<User>(0);
/** The {@link Right}s this role have in the user management system. */
private Set<Right> rights = new HashSet<Right>(0);
/**
* Default constructor.
*/
public Role() {
super();
}
/**
* Constructor for the not-nullable attributes.
*
* @param name
* The name of the role.
* @param type
* The type of the role.
* @param lastUpdated
* The time of the last update of the role.
*/
public Role(String name, String type, Date lastUpdated) {
this.name = name;
this.type = type;
this.lastUpdated = lastUpdated;
}
/**
* Constructor for all attributes.
*
* @param name
* The name of the role.
* @param description
* The description of the role.
* @param type
* The type of the role.
* @param lastUpdated
* The time of the last update of the role.
* @param users
* The {@link User}s who have this role.
* @param rights
* The {@link Right}s this role have.
*/
public Role(String name, String description, String type, Date lastUpdated,
Set<User> users, Set<Right> rights) {
this.name = name;
this.description = description;
this.type = type;
this.lastUpdated = lastUpdated;
this.users = users;
this.rights = rights;
}
/**
* The getter for the identifier of the role.
*
* @return The id of the role.
*/
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
/**
* The getter for the identifier of the role.
*
* @param id
* The id of the role.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* The getter for the name of the role.
*
* @return The name of the role.
*/
@Column(name = "name", nullable = false, length = 25)
public String getName() {
return this.name;
}
/**
* The setter for the name of the role.
*
* @param name
* The name of the role.
*/
public void setName(String name) {
this.name = name;
}
/**
* The getter for the description of the role.
*
* @return The description of the role.
*/
@Column(name = "description", length = 200)
public String getDescription() {
return this.description;
}
/**
* The setter for the description of the role.
*
* @param description
* The description of the role.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* The getter for the type of the role.
*
* @return The type of the role.
*/
@Column(name = "type", nullable = false, length = 10)
public String getType() {
return this.type;
}
/**
* The setter for the type of the role.
*
* @param type
* The type of the role.
*/
public void setType(String type) {
this.type = type;
}
/**
* The getter for the time of the last update of the role.
*
* @return The time of the last update of the role.
*/
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "last_updated", nullable = false, length = 19)
public Date getLastUpdated() {
return this.lastUpdated;
}
/**
* The setter for the time of the last update of the role.
*
* @param lastUpdated
* The time of the last update of the role.
*/
public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
/**
* The getter for the {@link User}s who have this role.
*
* @return The {@link User}s who have this role.
*/
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "t_users_roles", catalog = "test", joinColumns = { @JoinColumn(name = "roles_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "users_id", nullable = false, updatable = false) })
public Set<User> getUsers() {
return this.users;
}
/**
* The setter for the {@link User}s who have this role.
*
* @param users
* The {@link User}s who have this role.
*/
public void setUsers(Set<User> users) {
this.users = users;
}
/**
* The getter for the {@link Right}s this role have.
*
* @return The {@link Right}s this role have.
*/
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "t_roles_rights", catalog = "test", joinColumns = { @JoinColumn(name = "roles_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "rights_id", nullable = false, updatable = false) })
public Set<Right> getRights() {
return this.rights;
}
/**
* The setter for the {@link Right}s this role have.
*
* @param rights
* The {@link Right}s this role have.
*/
public void setRights(Set<Right> rights) {
this.rights = rights;
}
/**
* The string representation of this role.
*
* @return This role as a {@link String}.
*/
@Override
public String toString() {
StringBuffer strBuff = new StringBuffer();
strBuff.append("[Role:id=");
strBuff.append(id);
strBuff.append(",name=");
strBuff.append(name);
strBuff.append(",description=");
strBuff.append(type);
strBuff.append(",lastUpdated=");
strBuff.append(lastUpdated);
strBuff.append("]");
return strBuff.toString();
}
}
Code:
-- -----------------------------------------------------
-- Table `test`.`t_roles`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `test`.`t_roles` (
`id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique role identifier' ,
`name` VARCHAR(25) NOT NULL COMMENT 'Name of the role' ,
`description` VARCHAR(200) NULL DEFAULT NULL COMMENT 'Description of the role' ,
`type` ENUM('USER','CUSTOMER') NOT NULL COMMENT 'Type of the role' ,
`last_updated` TIMESTAMP NOT NULL COMMENT 'Last update of the entry' ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB
COMMENT = 'Roles of the test usermanagement module.';
-- -----------------------------------------------------
-- Table `test`.`t_rights`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `test`.`t_rights` (
`id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique right identifier' ,
`name` VARCHAR(25) NOT NULL COMMENT 'Name of the right' ,
`description` VARCHAR(200) NULL COMMENT 'Description of the right' ,
`type` ENUM('USER','CUSTOMER') NOT NULL COMMENT 'Type of the right' ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB
COMMENT = 'Rights of the test usermanagement module.';
-- -----------------------------------------------------
-- Table `test`.`t_users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `test`.`t_users` (
`id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique user identifier' ,
`nickname` VARCHAR(30) NOT NULL COMMENT 'Nickname of the backend user' ,
`password` VARCHAR(65) NOT NULL COMMENT 'Password of the backend user' ,
`first_name` VARCHAR(50) NOT NULL COMMENT 'First name of the backend user' ,
`second_name` VARCHAR(50) NOT NULL COMMENT 'Second name of the backend user' ,
`status` ENUM('ACTIVATED','DEACTIVATED') NOT NULL COMMENT 'Status of the user account' ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB
COMMENT = 'Users of the test usermanagement module.';
-- -----------------------------------------------------
-- Table `test`.`t_roles_rights`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `test`.`t_roles_rights` (
`roles_id` TINYINT UNSIGNED NOT NULL COMMENT 'FK identifier referring to t_roles' ,
`rights_id` TINYINT UNSIGNED NOT NULL COMMENT 'FK identifier referring to t_rights' ,
PRIMARY KEY (`roles_id`, `rights_id`) ,
INDEX `FK_rr_roles_id` (`roles_id` ASC) ,
INDEX `FK_rr_rights_id` (`rights_id` ASC) ,
CONSTRAINT `FK_rr_roles_id`
FOREIGN KEY (`roles_id` )
REFERENCES `test`.`t_roles` (`id` )
ON DELETE CASCADE
ON UPDATE NO ACTION,
CONSTRAINT `FK_rr_rights_id`
FOREIGN KEY (`rights_id` )
REFERENCES `test`.`t_rights` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'Junction table of t_roles and t_rights.';
-- -----------------------------------------------------
-- Table `test`.`t_users_roles`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `test`.`t_users_roles` (
`users_id` SMALLINT UNSIGNED NOT NULL ,
`roles_id` TINYINT UNSIGNED NOT NULL ,
PRIMARY KEY (`users_id`, `roles_id`) ,
INDEX `FK_ur_users_id` (`users_id` ASC) ,
INDEX `FK_ur_roles_id` (`roles_id` ASC) ,
CONSTRAINT `FK_ur_users_id`
FOREIGN KEY (`users_id` )
REFERENCES `test`.`t_users` (`id` )
ON DELETE CASCADE
ON UPDATE NO ACTION,
CONSTRAINT `FK_ur_roles_id`
FOREIGN KEY (`roles_id` )
REFERENCES `test`.`t_roles` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'Junction table of t_users and t_roles';
Code:
-- -----------------------------------------------------
-- t_roles
-- -----------------------------------------------------
INSERT INTO test.t_roles(name, description, type) VALUES ('Admin', 'Administrator.', 'User');
INSERT INTO test.t_roles(name, description, type) VALUES ('Reporter', 'Reporter.', 'User');
INSERT INTO test.t_roles(name, description, type) VALUES ('CallcenterEmployee', 'Callcenter employee.', 'User');
INSERT INTO test.t_roles(name, description, type) VALUES ('NormalCustomer', 'Normal customer.', 'Customer');
INSERT INTO test.t_roles(name, description, type) VALUES ('PremiumCustomer', 'Premium customer.', 'Customer');
-- -----------------------------------------------------
-- t_rights
-- -----------------------------------------------------
INSERT INTO test.t_rights(name, description, type) VALUES ('Read Users', 'Read only the user profile.', 'User');
INSERT INTO test.t_rights(name, description, type) VALUES ('Edit Users', 'Edit the user profile.', 'User');
INSERT INTO test.t_rights(name, description, type) VALUES ('Read Roles', 'Read only the role profile.', 'User');
INSERT INTO test.t_rights(name, description, type) VALUES ('Edit Roles', 'Edit the role profile.', 'User');
-- -----------------------------------------------------
-- t_users
-- -----------------------------------------------------
INSERT INTO test.t_users(nickname, password, first_name, second_name, status) VALUES ('Paule', 'PaulsPassword', 'Paul', 'Poulsen', 'ACTIVATED');
INSERT INTO test.t_users(nickname, password, first_name, second_name, status) VALUES ('Peterchen', 'PetersPassword', 'Peter', 'Peterson', 'ACTIVATED');
INSERT INTO test.t_users(nickname, password, first_name, second_name, status) VALUES ('Susi', 'SusannesPassword', 'Susanne', 'Sorglos', 'ACTIVATED');
INSERT INTO test.t_users(nickname, password, first_name, second_name, status) VALUES ('Annchen', 'AnnesPassword', 'Anne', 'Andacht', 'ACTIVATED');
INSERT INTO test.t_users(nickname, password, first_name, second_name, status) VALUES ('Claudi', 'ClaudiasPassword', 'Claudia', 'Claasen', 'ACTIVATED');
INSERT INTO test.t_users(nickname, password, first_name, second_name, status) VALUES ('Basti', 'SebastiansPassword', 'Sebastian', 'Sbel', 'ACTIVATED');
INSERT INTO test.t_users(nickname, password, first_name, second_name, status) VALUES ('Klausi', 'KlausPassword', 'Klaus', 'Klaunson', 'ACTIVATED');
INSERT INTO test.t_users(nickname, password, first_name, second_name, status) VALUES ('Chris', 'ChristophsPassword', 'Christoph', 'Christopherus', 'DEACTIVATED');
-- -----------------------------------------------------
-- t_roles_rights
-- -----------------------------------------------------
INSERT INTO test.t_roles_rights(roles_id, rights_id) VALUES ('1','1');
INSERT INTO test.t_roles_rights(roles_id, rights_id) VALUES ('1','2');
INSERT INTO test.t_roles_rights(roles_id, rights_id) VALUES ('1','3');
INSERT INTO test.t_roles_rights(roles_id, rights_id) VALUES ('1','4');
INSERT INTO test.t_roles_rights(roles_id, rights_id) VALUES ('2','2');
INSERT INTO test.t_roles_rights(roles_id, rights_id) VALUES ('3','3');
INSERT INTO test.t_roles_rights(roles_id, rights_id) VALUES ('3','4');
-- -----------------------------------------------------
-- t_users_roles
-- -----------------------------------------------------
INSERT INTO test.t_users_roles(users_id, roles_id) VALUES ('1','1');
INSERT INTO test.t_users_roles(users_id, roles_id) VALUES ('2','1');
INSERT INTO test.t_users_roles(users_id, roles_id) VALUES ('3','3');
INSERT INTO test.t_users_roles(users_id, roles_id) VALUES ('4','3');
INSERT INTO test.t_users_roles(users_id, roles_id) VALUES ('5','3');
INSERT INTO test.t_users_roles(users_id, roles_id) VALUES ('6','2');
INSERT INTO test.t_users_roles(users_id, roles_id) VALUES ('7','2');
INSERT INTO test.t_users_roles(users_id, roles_id) VALUES ('8','2');
Code:
DROP TABLE IF EXISTS `test`.`t_users_roles`;
DROP TABLE IF EXISTS `test`.`t_roles_rights`;
DROP TABLE IF EXISTS `test`.`t_users`;
DROP TABLE IF EXISTS `test`.`t_rights`;
DROP TABLE IF EXISTS `test`.`t_roles`;