I'm trying to setup some junit tests to verify that the backend matches what was just submitted, but I'm having a hard time actually finding the data that hasn't been commited yet.
In this part, I'm creating a new job and then setting the job parameters
Code:
Job job = new Job();
job.setJobType(jobType);
job.setJobState(jobState);
job.setAccount(account);
session.save(job);
for( String name : parameters.keySet() ) {
JobParameter jobParameter = new JobParameter();
jobParameter.setJob(job);
jobParameter.setName(name);
jobParameter.setValue(parameters.get(name));
session.save(jobParameter);
}
So then I want to check the values, without commiting. At first, when I did a job.getJobParameters(), it wouldn't return anything, but then I added a session.refresh(job), and then it worked.
My question is, is there any way to have hibernate be able to identify that it needs to do a refresh itself when a collection has been updated associated to that object? In this case, that Hibernate knows that the JobParameters of the Job have been updated and when the collection is called to refresh?