/** * Return the EclipseLink cache key object from the JPA Id object. */ private Object createPrimaryKeyFromId(Class cls, Object id) { Object cacheKey = null; ClassDescriptor aDescriptor = getSession().getDescriptor(cls); // Check that we have a descriptor associated with the class (Entity or MappedSuperclass) if(null == aDescriptor) { // No descriptor found, throw exception for Embeddable or non-persistable java class throw new IllegalArgumentException(ExceptionLocalization.buildMessage( "cache_impl_class_has_no_descriptor_is_not_a_persistent_type", new Object[] {cls})); } // The policy is not set if the mapping is natively defined outside of JPA if(aDescriptor.hasCMPPolicy()) { // we assume that the PK id parameter is correct and do not throw a cache_descriptor_has_no_cmppolicy_set_cannot_create_primary_key exception // The primaryKey may be the same object as the id parameter cacheKey = aDescriptor.getCMPPolicy().createPrimaryKeyFromId(id, getEntityManagerFactory().getDatabaseSession()); } return cacheKey; }
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] { descriptor.getCMPPolicy().getPKClass(), id.getClass() })); primaryKey = policy.createPrimaryKeyFromId(id, session);
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] { descriptor.getCMPPolicy().getPKClass(), id.getClass() })); primaryKey = descriptor.getCMPPolicy().createPrimaryKeyFromId(id, this); } else { if (!id.getClass().equals(theClass)) {
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("invalid_pk_class", new Object[] { descriptor.getCMPPolicy().getPKClass(), id.getClass() })); primaryKey = descriptor.getCMPPolicy().createPrimaryKeyFromId(id, this); } else { if (!id.getClass().equals(theClass)) {