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?
|
|