Skip to main content

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

I might be wrong, but I guess your problem is in the cache. Eclipselink is probably not triggering a new select in the database, but you can be sure of it by increasing the debugging level.

If it is indeed a caching problem, you should be able to solve it by disabling the cache on the Part entity:
http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_cache.htm

If you want to be able to change your database from sources other than your JPA application you run into these kind of problems.

André Prata


On Thu, Apr 10, 2014 at 10: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