I have a general question that I can't seem to find a solid answer to so I will post it here:
Hibernate gives us the option to specify 1-1, 1-N, N-1, N-M relationships and also cascading options as well. What about the database level options for cascading after specifying foreign keys and such at the database level?
Example:
Code:
CREATE TABLE parent (
id INT NOT NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
CREATE TABLE child (
id INT,
parent_id INT,
FOREIGN KEY (parent_id) REFERENCES parent(id)
ON DELETE CASCADE
) ENGINE=INNODB;
How does the equivalent hbm.xml file look like for this requirement? Do I need to create these tables with the FOREIGN KEY? If not, does the application need to handle this relationship? Is there a way to keep the FOREIGN KEY option so that the database can handle this relationship instead of hibernate? What are my options?