Hello,
I'm developing a blog that is based in the User entity of our system (the blog is just a module of the system), so a Post is owned by an User, and the User entity doesn't know the existance of the Blog module.
What I can do, to when a user be deleted, all the posts owned by it, be deleted too?
* Put <set> in User, and a cascade style isn't a good solution, as I said, the system is modular, and put things in User for every module that is running on the system isn't a good solution.
Best regards,
-Adriano
Hibernate version:
Hibernate 3.1.3
Mapping documents:
This is just an example to illustrate.
Code:
<hibernate-mapping package="foo.bar.model">
<class name="Post" table="posts">
<id name="id" type="long">
<generator class="native" />
</id>
<property name="name" />
<many-to-one name="username" class="User" />
</class>
<class name="User" table="users">
<id name="id" type="long">
<generator class="native" />
</id>
<property name="name" />
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
SEVERE: ERROR: update or delete on "users" violates foreign key constraint "fk65e7bd3dd853372" on "posts"
Detail: Key (id)=(19) is still referenced from table "posts".
Name and version of the database you are using:
PostgreSQL, version: 8.1.3