Question Is there any way to read values from an entity bean without
locking it for the rest of the transaction (e.g. readonly transactions)? We
have a key-value map bean which deadlocks during some concurrent reads.
Isolation levels seem to affect the database only, and we need to work within
a transaction. (EJB)
Answer The only thing that comes to (my) mind is that you could write a 'group
accessor' - a method that returns a single object containing all of your entity
bean's attributes (or all interesting attributes). This method could then be placed
in a 'Requires New' transaction. This way, the current transaction would be
suspended for the duration of the call to the entity bean and the entity bean's
fetch/operate/commit cycle will be in a separate transaction and any locks should
be released immediately. Depending on the granularity of what you need to pull
out of the map, the group accessor might be overkill.
Question What is the difference between a "Coarse Grained" Entity Bean
and a "Fine Grained" Entity Bean? (EJB)
Answer A 'fine grained' entity bean is pretty much directly mapped to one
relational table, in third normal form. A 'coarse grained' entity bean is larger and
more complex, either because its attributes include values or lists from other
tables, or because it 'owns' one or more sets of dependent objects.
Note that the coarse grained bean might be mapped to a single table or flat
file, but that single table is going to be pretty ugly, with data copied from
other tables, repeated field groups, columns that are dependent on non-key
fields, etc. Fine grained entities are generally considered a liability in large
systems because they will tend to increase the load on several of the EJB
Do'stlaringiz bilan baham: |