Page 1 of 1

About Question enthuware.oce-jpad.v6.2.454 :

Posted: Fri Feb 13, 2015 12:37 pm
by madouat
I've doubt about this answer (it should be false false).
Since CheckingAccount is of type Account and c.evict(Account.class) will remove all account class and it's subtypes. So, c.evict(Account.class, 31) should remove CheckingAccount instance with PK 31.

Regards,

Re: About Question enthuware.oce-jpad.v6.2.454 :

Posted: Fri Feb 13, 2015 10:02 pm
by admin
You could be right, but the specification is not clear about it. That is what the explanation also says:
The Cache API documentation for evict(class), clearly mentions that all instances of the class *and its subclasses* are evicted. However, when you call evict(class, PK), the API does not mention anything about a subclass. Thus, it can be interpreted only the instance of the given class with the given primary key will be evicted.

Re: About Question enthuware.oce-jpad.v6.2.454 :

Posted: Wed Mar 25, 2015 6:25 am
by stiekemaj
Although I agree with the vagueness of the API, I really hope that the real exam will not contain this kind of questions that can only be answered correctly when you know this kind of futile details by heart.

Re: About Question enthuware.oce-jpad.v6.2.454 :

Posted: Wed Mar 25, 2015 7:09 am
by admin
You might find a couple of such questions. We have included a few such questions in the question bank only to make you aware of this issue.

HTH,
Paul.

Re: About Question enthuware.oce-jpad.v6.2.454 :

Posted: Tue Apr 21, 2015 5:09 am
by Viorel Ghelbert
Hi,

In EclipseLink v2.5.2

Code: Select all

Cache c = emf.getCache();

Boolean flag1 = c.contains(Account.class, 31);
Boolean flag2 = c.contains(CheckingAccount.class, 31);
System.out.println(flag1 + " " + flag2);

c.evict(Account.class, 31);

flag1 = c.contains(Account.class, 31);
flag2 = c.contains(CheckingAccount.class, 31);
System.out.println(flag1 + " " + flag2);
yields
true true
false false
BTW, the JavaDoc for Cache#contains(Class cls, Object primaryKey) also does not explicitly specify whether subclasses should be included. EclipseLink thinks they should, that's why even before calling evict it does *not* print
false true
Personally, I think the semantics of all these 3 methods w.r.t. subclasses was intended to be the same, because it's more convenient, and it's probably how most of the providers implemented it and also how the exam would expect us to answer.

Re: About Question enthuware.oce-jpad.v6.2.454 :

Posted: Sat Jul 08, 2017 7:57 pm
by himaiMinh
With regard to how EclipseLink implements this Cache.evict() method, I cannot rely on any provider's implementation.
Some provider implements this without following the specification.