-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problem with unidirecional mapping
PostPosted: Thu Jun 29, 2006 9:35 pm 
Newbie

Joined: Thu Jun 29, 2006 9:02 pm
Posts: 3
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 1:34 am 
Newbie

Joined: Thu Jun 29, 2006 9:02 pm
Posts: 3
What I want in Post entity is like the functionality of "ON DELETE CASCADE" of the relational databases, that, when User is deleted, all the Posts that are owned by that user got deleted too.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.