I have inherited a legacy system.
basic architecture ....
Oracle DBMSJPA/HibernateEJB3JBoss 5Struts 1
This single application has multiple(many)
EJB Jars (which contain JPA entities) to access a singular database.
As such if a WAR needs to access to data managed across say 3 EJB Jars, it has to compose the data from the three Jars before applying business logic and/or rendering of that data.
Simple (worst case) example ...
Setup of data....
You have the following entities buildings, rooms, people.
Buildings have multiple rooms, each room can house multiple people.
Business logic...
List all buildings(only buildings) with buildings in City A, Rooms on 2nd Floor, People with last name Smith.
The current system is forced(at a minimum) to use the Buildings EJB to find all buildings in City A, The Rooms EJB to find all on the 2nd floor, and people EJB to find all with last name Smith, Then cross reference the lists (in essence do the joining) to determine the final list.
Keep in mind this is all in the same database in which each EJB has access to all tables but only JPA Entities for the items it manages.
Each EJB jar has it's own container injected EntityManager.
MY QUESTION: Am I correct that the following would not be safe from a data integrity stand point?
Have Building EJB execute a single query across Buildings,Rooms, and people to find the Buildings of interest.
As I understand it since the Rooms and People are 'managed' by there own EntityManagers, there is no gaurantee of when data commits to those entity's tables will take place. As such the Buildings EJB may be querying against old data, because a single entitymanager is not used.