However, those locks limit concurrency and scalability when
multiple transactions are executing insert statements at the
same time
For INSERT statements where the
number of rows to be inserted is known at the beginning of
processing the statement, InnoDB quickly
allocates the required number of auto-increment values without
taking any lock, but only if there is no concurrent session
already holding the table-level AUTO-INC lock
(because that other statement will be allocating auto-increment
values one-by-one as it proceeds)
obtains
auto-increment values under the control of a mutex (a
light-weight lock) that is not held until
the statement completes, but only for the duration of the
allocation process
recovery scenarios when SQL statements are
replayed from the binary log
Using auto-increment with replication
set
innodb_autoinc_lock_mode to
0 or 1 and use the same value on the master and its slaves
Auto-increment values are not ensured to be the same on the
slaves as on the master if you use
innodb_autoinc_lock_mode =
2 (“interleaved”) or configurations where the
master and slaves do not use the same lock mode
When updating existing entities coming from the database
id is defined and is maintained
in the three layers during the different serialization/persistence operations
when a new entity is being created in any of the two upper layers (Flex/JPA)
new entity has no id until it has been persisted to the database
most common solution is to
have a second persisted id, the uid
which is created by the client and persisted along with the entity
recommended approach to avoid any kind of subtle problems is to have a real uid property which will be persisted
in the database but is not a primary key for efficiency concerns
You can now ask Tide to
limit the object graph before sending it
Flex with the following API :
EntityGraphUnintializer
uninitializeEntityGraph
Person object will be uninitialized
uperson contains
only the minimum of data
to correctly merge your changes in the server persistence context
Tide uses the
client data tracking
to determine which parts of the graph
need to be sent
Calling the EntityGraphUninitializer manually is a bit tedious and ugly, so there is a cleaner possibility when you are using
generated typesafe service proxies
annotate your service method arguments with @org.granite.tide.data.Lazy :
@Lazy
take care that you have added the [Lazy] annotation to your Flex
metadata compilation configuration
in the Flex application, register the UninitializeArgumentPreprocessor component in Tide as follows :
[UninitializeArgumentPreprocessor]
all calls to PersonService.save() will
automatically use a properly uninitialized version
of the person
argument.
15.4. Dirty Checking and Conflict Handling
simplify the handling of data between Flex and Java EE
Chapter 15. Data Management
Tide maintains a client-side cache of entity instances and ensures that every instance is unique in the Flex client context
uid().hashCode();
Tide currently only supports Integer or Long version fields, not timestamps and that the field must be nullable