(Edited)
Without any reference to frameworks like Spring or Hibernate, you can simply set up your database tables with constraints on the foreign key columns in order to delete all related records when the "user" record is deleted. The constraint is referred to as ON DELETE CASCADE, and if you define it on the foreign key column of a joined table, the RDBMS will automatically delete all the records for which the foreign key matches the selected user ID of the deleted record.
Try doing some research on the ON DELETE CASCADE constraint specifically for the database server you are using for more details.
(Edit #2)
Here is a modified example from the MySQL documentation:
CREATE TABLE product (
category INT NOT NULL, id INT NOT NULL,
price DECIMAL,
PRIMARY KEY(category, id)
) ENGINE=INNODB;
CREATE TABLE customer (
id INT NOT NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
CREATE TABLE product_order (
no INT NOT NULL AUTO_INCREMENT,
product_category INT NOT NULL,
product_id INT NOT NULL,
customer_id INT NOT NULL,
PRIMARY KEY(no),
INDEX (product_category, product_id),
INDEX (customer_id),
FOREIGN KEY (product_category, product_id)
REFERENCES product(category, id)
ON DELETE CASCADE,
FOREIGN KEY (customer_id)
REFERENCES customer(id)
) ENGINE=INNODB;
The example shows a relationship between product and product_order. When deleting a record from the product table (just simply running DELETE FROM product WHERE id=... and category=...), all the referenced records in the product_order table will be automatically deleted without any additional SQL statements.
On the other hand, when deleting a row from the customer table you will get the same error you are getting now, because the default constraint restricts delete operations on records in that case.