-->
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.  [ 1 post ] 
Author Message
 Post subject: Identifier Generation Strategy
PostPosted: Fri Jan 14, 2011 6:12 am 
Beginner
Beginner

Joined: Tue Nov 02, 2010 4:29 am
Posts: 21
I am considering an identifier generation strategy that creates all (transient) model objects in a factory that assigns a randomly generated, unique id.
The singleton factory implementations will either use an in memory list (for testing) or a persisted list of already assigned ids to avoid creating duplicates. This also avoids reusing ids of deleted objects which could cause later problems on relationships. I know this requires a database hit although I assume one could cache the id list to improve performance at the expense of memory ~ 8MB for a million entities. Although this might cause problems if the app crashes before the cached list is synchronised. At the very least one could avoid having to read before creation with a synchronisation write with other writes.
This also avoids the need to use business keys for the hash and equals implementation - the database id being used instead.
I want to use randomly generated IDs to increase security - people won't be able to guess URL parameters by looking at a current one and incrementing it.

The alternative to the factory is using a custom identifier generator and using a business key for equals and hash. In this case I would just compare all of the non relationship (value) fields for equality.

Thoughts? Feedback?


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

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.