-->
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.  [ 5 posts ] 
Author Message
 Post subject: delete best practice
PostPosted: Thu Aug 04, 2005 12:32 pm 
Beginner
Beginner

Joined: Thu Oct 23, 2003 1:17 pm
Posts: 44
I'm wondering what most people do when handling objects that are "deleted" by the front end, and not needed anymore. I put "deleted" in quotes because at previous jobs, we never really deleted rows, we just set the status != 1.

How do you guys handle it?

Lets say a user has a list of emails that they can add and remove. When the user removes one from the list, do you do a real delete, and it's gone for good? Is it bad to just delete the row and lose data?

It seems safer to not really delete them, just flag it with an inactive status. But when I do that, and I load an object, it loads all the items in it's collection, and doesn't care about my status flag. I realize I can filter these out, but it seems like a pain to do all the time for everything that's loaded, so I'm just wonder what other people do.

Thanks for your thoughts.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 12:43 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
You can of course do a real delete on your objects, but it depends on your data model as well as on the question, whether you need auditing or not.

In your example you can of course delete the e-mail, if there a no other important dependencies. Probably it is more interesting to ask, whether you can delete a user. Often you only want to deactivate the user. In this case a flag "inactive" will do the job. When loading the users you can do it with HQL, for example.

Code:
select u from User u where u.inactive = :state


Best regards,
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 12:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Good usecase for a HB3 filter?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 12:51 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
gavin wrote:
Good usecase for a HB3 filter?


Probably. :)

@squeebie
See: http://www.hibernate.org/hib_docs/v3/re ... e/#filters


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 8:06 pm 
Beginner
Beginner

Joined: Thu Oct 23, 2003 1:17 pm
Posts: 44
Ah, I hadn't seen the HB3 filters, they're exactly what I was looking for. I should've known Hibernate would have an easy way to solve my problem :)

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.