Hi, all. I'm totally stuck with following scenario.
I have entity A which identified by business key id. So when we create A we specify ID rather than let Hibernate generate it. Imagine it, i.e. as user, identified by username. I have also entity B which is related as many-to-one to entity A, and which is identified by generated ID. Relation is unidirectional, A knows nothing about B. Imagine it, i.e. as messages issued by user.
Let us simultaneously launch a bunch of transactions that mean: create new B related to A, identified by same ID. At the moment all transactions start, we do not have such A in database. How to make sure that all transactions create only one A and lots of B-s?
Well yeah, I can do it with additional transaction launched by future-based cache, but transactions are RESOURCE_LOCAL and future can return some initialized result before data will be actually commited, and other transactions trying to use this data will fail.
Thanks in advance for help
|