/** * INTERNAL: */ public String getPKClassName() { String pkClassName = null; if (m_descriptor.hasCMPPolicy()) { pkClassName = ((CMP3Policy) m_descriptor.getCMPPolicy()).getPKClassName(); } return pkClassName; }
if (descriptor.hasCMPPolicy()) { CMP3Policy policy = (CMP3Policy) descriptor.getCMPPolicy(); return policy.createPrimaryKeyInstanceFromPrimaryKeyValues((AbstractSession) session, new int[] { 0 }, keyElements);
if(this.getDescriptor().hasCMPPolicy()) { pkClass = ((CMP3Policy)this.getDescriptor().getCMPPolicy()).getPKClass(); if(null == pkClass) {
if (descriptor.hasCMPPolicy()) { CMP3Policy policy = (CMP3Policy) descriptor.getCMPPolicy(); return policy.createPrimaryKeyInstanceFromPrimaryKeyValues((AbstractSession) session, new int[] { 0 }, keyElements);
/** * 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; }
/** * This method will return the objects's Id. * If the descriptor associated with the domain object is null - an IllegalArgumentException is thrown. * If the CMPPolicy associated with the domain object's descriptor is null * the Id will be determined using the ObjectBuilder on the descriptor - which may return * the Id stored in the weaved _persistence_primaryKey field. * @See {@link JpaCache#getId(Object)} */ public Object getId(Object object) { getEntityManagerFactory().verifyOpen(); ClassDescriptor aDescriptor = getSession().getDescriptor(object.getClass()); // Handle a null descriptor from a detached entity (closed EntityManager), or the entity exists in another session if(null == aDescriptor) { throw new IllegalArgumentException(ExceptionLocalization.buildMessage( "cache_impl_object_has_no_descriptor_is_not_a_persistent_type", new Object[] {object})); } // Handle a null CMPPolicy from a MappedSuperclass if(!aDescriptor.hasCMPPolicy()) { // the following code gets the key either from the weaved _persistence_primaryKey field or using valueFromObject() if not bytecode enhanced return aDescriptor.getObjectBuilder().extractPrimaryKeyFromObject(object, (AbstractSession)getSession()); } else { // Get identifier via EMF return getEntityManagerFactory().getIdentifier(object); } }
List<DatabaseMapping> pkMappings = descriptor.getObjectBuilder().getPrimaryKeyMappings(); Object entity = null; if (descriptor.hasCMPPolicy()) { CMP3Policy policy = (CMP3Policy) descriptor.getCMPPolicy(); entity = policy.createBeanUsingKey(id, (AbstractSession) context.getServerSession());
List<DatabaseMapping> pkMappings = descriptor.getObjectBuilder().getPrimaryKeyMappings(); Object entity = null; if (descriptor.hasCMPPolicy()) { CMP3Policy policy = (CMP3Policy) descriptor.getCMPPolicy(); entity = policy.createBeanUsingKey(id, (AbstractSession) context.getServerSession());
/** * INTERNAL: * This method is used to load a relationship from a list of PKs. * This list may be available if the relationship has been cached. */ public Object valueFromPKList(Object[] pks, AbstractSession session) { Vector pk = null; if (pks[0] == null) return null; if (getReferenceDescriptor().hasCMPPolicy()) { pk = getReferenceDescriptor().getCMPPolicy().createPkVectorFromKey(pks[0], session); } else { pk = (Vector) pks[0]; } ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(getReferenceClass()); query.setSelectionKey(pk); query.setIsExecutionClone(true); return session.executeQuery(query); }
/** * INTERNAL: * This method is used to load a relationship from a list of PKs. This list * may be available if the relationship has been cached. */ public Object valueFromPKList(Object[] pks, AbstractSession session){ ContainerPolicy cp = this.containerPolicy; Object result = cp.containerInstance(pks.length); for (int index = 0; index < pks.length; ++index){ Vector pk = null; if (getReferenceDescriptor().hasCMPPolicy()){ pk = getReferenceDescriptor().getCMPPolicy().createPkVectorFromKey(pks[index], session); }else{ pk = (Vector)pks[index]; } ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(getReferenceClass()); query.setSelectionKey(pk); query.setIsExecutionClone(true); cp.addInto(session.executeQuery(query), result, session); } return result; }
this.instantiationPolicy.convertClassNamesToClasses(classLoader); if (hasCMPPolicy()) { getCMPPolicy().convertClassNamesToClasses(classLoader);
this.instantiationPolicy.convertClassNamesToClasses(classLoader); if (hasCMPPolicy()) { getCMPPolicy().convertClassNamesToClasses(classLoader);
this.instantiationPolicy.convertClassNamesToClasses(classLoader); if (hasCMPPolicy()) { getCMPPolicy().convertClassNamesToClasses(classLoader);