Lets say I have three Jobs currently running, two of which are identical... so:
CrawlJob job1 = new CrawlJob();
CrawlJob job2 = new CrawlJob();
CurrentJob job3 = new CurrentJob();
job1.now()
job2.now()
job3.now()
If I do the following in job1:
JPA.em().flush();
JPA.em().clear();
Will that also detach all the entities that job2 and job3 are currently processing? Meaning if I'm passing around an entity/Model Object in job2/job3 that I looked up in the database, is job2/job3 liable to break because the Object will have just been detached from the session?
Similarly, lets say I do the following in job1:
long id = 123
User user1 = new User(id);
user1.save();
And then in job2 or job3 I do:
User user2 = User.findById(id);
will user2 be equal to "null" or equal to "user1"? Meaning, even though user1 has NOT yet been flushed/committed to the database, will job2 or job3 be able to look it up by Id?
I think what both these questions are getting at is whether Jobs (regardless of whether they are instantiations of the same Job or a different Job) share EntityManagers and thus .em().flush(), .em().clear() or .em().getTransaction().commit() OR Model.save() will affect all the Jobs at the same time?