I have existing project which uses 2 database (DB2),and the records which are saved in the 2 databases are related.So the transactions need to be maintained.Eg whenever a new thing is to be added then entries must be done to x number of tables in Database1 and and y number of tables in database2. Now in the code that is preexisting(developed by somone else) i see some thing like
UserTransaction utx = getTranscationU();
//getTranscation() is a user defined method as show below
public UserTransaction getTransactionU() {
InitialContext ic = new InitialContext();
return (UserTransaction) ic.lookup("java:comp/XYZ");
}
so in code following sequence is followed: 1)start utx 2)create a seperate entity manager ems for db1 and db2 3)create entries in both tables using this ems 4)if any exception is thrown then rollback utx
Now my question is
- 1)will this code make sure that entries are entered in both db or none of them?
- 2)Can any one explain me what does code inside getTransactionU() does?
- 3)where is XYZ defined?