Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Eclipselink CascadeTypes Refresh

What happens if you try one or the latest nightly builds - 2.6 for instance?  It sounds like a bug, but I have difficulty finding the issue I'm thinking of to verify when it was fixed or if it is related.



On Apr 10, 2014, at 5:15 AM, steffen.herter@xxxxxx wrote:

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

 

 

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top