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

Moderator: admin

Post Reply
madouat
Posts: 2
Joined: Fri Feb 13, 2015 12:30 pm
Contact:

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

Post by madouat » Fri Feb 13, 2015 12:37 pm

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,

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Fri Feb 13, 2015 10:02 pm

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.
If you like our products and services, please help us by posting your review here.

stiekemaj
Posts: 8
Joined: Sun Jan 25, 2015 6:08 am
Contact:

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

Post by stiekemaj » Wed Mar 25, 2015 6:25 am

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.

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Wed Mar 25, 2015 7:09 am

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.
If you like our products and services, please help us by posting your review here.

Viorel Ghelbert
Posts: 15
Joined: Fri Apr 10, 2015 12:53 pm
Contact:

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

Post by Viorel Ghelbert » Tue Apr 21, 2015 5:09 am

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.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

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

Post by himaiMinh » Sat Jul 08, 2017 7:57 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests