Hello,
i’ve a strange behavoir in my Application:
Eclipselink: 2.5.1
Javax-persisnence:2.0.1
WebApplication: JSF: 1.2
Caching: second Llevel cache activated
Weaving: static
Entities: Part, Tolerance
Class Part
@OneToMany(mappedBy =
"part",
targetEntity = Tolerance.class, fetch = FetchType.LAZY,
cascade = CascadeType.ALL)
@PrivateOwned
@BatchFetch(BatchFetchType.JOIN)
private List<Tolerance>
tolerances =
new ArrayList<Tolerance>();
Class Tolerance
@ManyToOne(optional =
false,fetch=FetchType.LAZY)
@JoinColumn(name =
"PD_ID", referencedColumnName =
"PD_ID")
private Part
part =
null;
When I navigate to the part view of a single part the function
loadPart(Part part) is called
Part refreshedPart =
partService.findById(part.getId());
partService.refresh(refreshedPart)
for (Tolerance curTolerance
: refreshedPart.getTolerances())
{
System.out.println(curTolerance.isManual());
}
The refresh of a part is needed because other Applications can change the manual flag of the tolerance table directly in database.
What happens:
·
Let’s say getTolerances() delivers 3 tolerance objects and the isManual Flag of all 3 is false.
·
I change the flag of all 3 in database and set it to true. The I click the refreshPage Button and the Page is reloaded and the loadPart(Part part) is called again
·
I suggest that the refresh cascade type triggers a database select statement when
refreshedPart.getTolerances()
·
I see that this select statement is called and the first sysout statement is correct and writes
true to the console
·
Now we have 2 more loops to go. The next sysouts are
false,false!?!? à what I expected is that all 3 sysouts write
true to the console
Does Anyone understand this behavior?
The following Workaround works:
Write toleranceService.refresh(curTolerance); in the loop. But in my opinion that is exactlxy what the cascadyType should do.
Kind regards
Steffen