PersistenceUnitUtil getIdentifier doesn't return the oid


In JPA, the equivalent to JDOHelper.getObjectId, seems to be PersistenceUnitUtil.getIdentifier. Trying to use it (test purposes) with the L2Cache I face an issue.

Using the model of the DN example, 
bookId =emf.getPersistenceUnitUtil().getIdentifier(book); // => Long, should be a LongId
emf.getCache().contains(Book.class, bookId); /=> false



Kindly quote sections of the JPA spec to back up your assertions if you are going to make statements about something being "wrong".
Such handling (PersistenceUnitUtil) was written over a long period of time in response to bug reports to people who reported such findings in GitHub. Using some internal class (LongId) would make little sense in a JPA context.

Whether Cache.contains is working correctly is a different question. But then you can easily get the code, work it out, contribute a test etc.


Ok, maybe I wrong about the specification getIdentifier, but I didn't find the alternative. 

I made a testcase for the issue I'm having.

I use specific DN API to check if L2Cache contains the object.

Then I have an issue with collection. They are none in the cached object, while I read it should.