users@glassfish.java.net

Design advice

From: <glassfish_at_javadesktop.org>
Date: Fri, 14 Mar 2008 05:15:06 PST

Hi,

Hi we have a method which gets a bunch of entities from the database. If these entities miss some information, which is stored in another table, we need to create this information. This information is only created once when one of these entities are requested for the first time. If this method is accessed by several clients at the same time for an entity and the additional data is not yet created I don't want the main method to fail.

Currently I have the main method that calls the get/create additional data method which creates a new transaction. If I get an error in this due to that another transaction already created this row of additional data I catch it in the main method and retries. Since it's very unlikely that this would happen I would prefer not to lock the table.

Do you have any design advice? Currently when the new transaction rolls back and I catch the error I get a lot of errors in my log which I cannot seem to get rid of even if I can handle the error.

Kind of confusing description but I hope you get it. And yes, I would prefer to have this additional data stored when the entities are added to the db but that's not possible...

Thanks for the help!
[Message sent by forum member 'woel' (woel)]

http://forums.java.net/jive/thread.jspa?messageID=263998