/*
Finds the findByPrimaryKey method in the bean's home interface
173012
private Method findFindByPrimaryKey(Class c)
    {
        Method[] methods = c.getMethods();

        for (int i = 0; i < methods.length; ++i)
        {
            if (methods[i].getName().equals("findByPrimaryKey"))
            {

                return methods[i];
            }
        }

        return null;
    }
1087235
function matchPrimaryKeys(model) {
    return model.primaryKeyAttributes.map(
        function(name) { return util.format('%s = NEW.%s', name, name)})
        .join(' AND ');
  }
1211004
private List<Object> findUsingLucene(EntityMetadata m, Client client, Object[] primaryKeys)
    {

        String idField = m.getIdAttribute().getName();
        String equals = "=";
        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                m.getPersistenceUnit());
        EntityType entityType = metaModel.entity(m.getEntityClazz());
        String columnName = ((AbstractAttribute) entityType.getAttribute(idField)).getJPAColumnName();
        List<Object> result = new ArrayList<Object>();
        Queue queue = getKunderaQuery().getFilterClauseQueue();
        KunderaQuery kunderaQuery = getKunderaQuery();

        for (Object primaryKey : primaryKeys)
        {
            FilterClause filterClause = kunderaQuery.new FilterClause(columnName, equals, primaryKey, idField);
            kunderaQuery.setFilter(kunderaQuery.getEntityAlias() + "." + columnName + " = " + primaryKey);
            queue.clear();
            queue.add(filterClause);
            List<Object> object = findUsingLucene(m, client);
            if (object != null && !object.isEmpty())
                result.add(object.get(0));
        }
        return result;
    }
1063443
String getPrimaryRangeKeyName(Class<?> clazz) {
        Method primaryRangeKeyGetter = getPrimaryHashKeyGetter(clazz);
        return primaryRangeKeyGetter == null ?
                null
                :
                getAttributeName(getPrimaryRangeKeyGetter(clazz));
    }
1125869
@Override
	public List<CommerceWarehouse> findByG_C_P(long groupId,
		long commerceCountryId, boolean primary) {
		return findByG_C_P(groupId, commerceCountryId, primary,
			QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}
174212
private <T> Provider<T> lookupProvider(Key<T> key)
  {
    BindingInject<T> bean = findBean(key);

    if (bean != null) {
      return bean.provider();
    }

    BindingAmp<T> binding = findBinding(key);

    if (binding != null) {
      return binding.provider();
    }

    binding = findObjectBinding(key);

    if (binding != null) {
      return binding.provider(InjectionPoint.of(key));
    }


    return null;
  }
347520
private Method findAddRemoveListenerMethod(Class<?> sourceClass, String methodName) throws IntrospectionException
	{
		try
		{
			return sourceClass.getMethod(methodName, listenerType);
		}
		catch (NoSuchMethodException e)
		{
			return findAddRemoveListnerMethodWithLessCheck(sourceClass, methodName);
		}
		catch (Exception e)
		{
			throw new IntrospectionException(Messages.getString("beans.31", //$NON-NLS-1$
					methodName, listenerType.getName()));
		}
	}
548045
@Override
    public <T> T find(Class<T> entityClass, Object primaryKey)
    {
        try
        {
            return ivEm.find(entityClass, primaryKey);
        } finally
        {
            if (!inJTATransaction())
            {
                ivEm.clear();
            }
        }
    }
199242
private <T> ResultIterable<T> findByExample(Class<?> type, Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> entity) {
        sessionContext.getCacheSynchronizationService().flush();
        EntityTypeMetadata<EntityMetadata> entityTypeMetadata = sessionContext.getMetadataProvider().getEntityMetadata(type);
        EntityDiscriminator entityDiscriminator = entityTypeMetadata.getDatastoreMetadata().getDiscriminator();
        if (entityDiscriminator == null) {
            throw new XOException("Type " + type.getName() + " has no discriminator (i.e. cannot be identified in datastore).");
        }
        ResultIterator<Entity> iterator = sessionContext.getDatastoreSession().getDatastoreEntityManager().findEntity(entityTypeMetadata, entityDiscriminator,
                entity);
        AbstractInstanceManager<EntityId, Entity> entityInstanceManager = sessionContext.getEntityInstanceManager();
        ResultIterator<T> resultIterator = new ResultIterator<T>() {

            @Override
            public boolean hasNext() {
                return iterator.hasNext();
            }

            @Override
            public T next() {
                Entity entity = iterator.next();
                return entityInstanceManager.readInstance(entity);
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException("Cannot remove instance.");
            }

            @Override
            public void close() {
                iterator.close();
            }
        };
        XOTransaction xoTransaction = sessionContext.getXOTransaction();
        final ResultIterator<T> transactionalIterator = xoTransaction != null ? new TransactionalResultIterator<>(resultIterator, xoTransaction)
                : resultIterator;
        return sessionContext.getInterceptorFactory().addInterceptor(new AbstractResultIterable<T>() {
            @Override
            public ResultIterator<T> iterator() {
                return transactionalIterator;
            }
        }, ResultIterable.class);
    }
371988
private void definePrimaryKey(ClassFile cf) {
        if (mPrimaryKey == null) {
            return;
        }

        // Add primary key annotation
        //
        // @PrimaryKey(value={"+/-propName", "+/-propName", ...})

        Annotation pk = cf.addRuntimeVisibleAnnotation(TypeDesc.forClass(PrimaryKey.class));

        Annotation.MemberValue[] props =
            new Annotation.MemberValue[mPrimaryKey.getPropertyCount()];
        pk.putMemberValue("value", props);
        int propPos = 0;
        Iterator<String> propNames = mPrimaryKey.getProperties();
        while (propNames.hasNext()) {
            String propName = propNames.next();
            props[propPos] = pk.makeMemberValue(propName);
            propPos++;
        }
    }
548236
private Method findFindByPrimaryKey(Class c)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "findFindByPrimaryKey", c);

        Method[] methods = c.getMethods();

        for (int i = 0; i < methods.length; ++i)
        {
            if (methods[i].getName().equals("findByPrimaryKey"))
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    Tr.exit(tc, "findFindByPrimaryKey");
                return methods[i];
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "findFindByPrimaryKey: method findByPrimaryKey not found!");
        return null;
    }
1225646
@Override
    public String getEnterpriseBeanClassName(Object homeKey)
    {
        HomeRecord hr = homesByName.get(homeKey); // d366845.3
        return hr.homeInternal.getEnterpriseBeanClassName(homeKey);
    }
368245
@Override
	public com.liferay.commerce.account.service.persistence.CommerceAccountUserRelPK getPrimaryKey() {
		return _commerceAccountUserRel.getPrimaryKey();
	}
534740
@Override
    public Object find(Class entityClass, Object key)
    {
        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                entityMetadata.getPersistenceUnit());

        AbstractManagedType managedType = (AbstractManagedType) metaModel.entity(entityMetadata.getEntityClazz());

        return managedType.hasLobAttribute() ? findGFSEntity(entityMetadata, entityClass, key) : find(entityClass, key,
                entityMetadata, metaModel, managedType);
    }
477791
public Class<?> getEJBPrimaryKeyClass(J2EEName j2eeName) {
        Class<?> rtnPKeyClass = null;
        BeanMetaData bmd = internalBeanMetaDataStore.get(j2eeName);
        if (bmd != null) {
            rtnPKeyClass = bmd.pKeyClass;
        }
        return rtnPKeyClass;
    }
1152663
@Override
	public com.liferay.commerce.account.service.persistence.CommerceAccountOrganizationRelPK getPrimaryKey() {
		return _commerceAccountOrganizationRel.getPrimaryKey();
	}
258951
public AbstractSpecWithPrimaryKey<T> withPrimaryKey(KeyAttribute ... components) {
        if (components == null)
            this.keyComponents = null;
        else
            this.keyComponents = Arrays.asList(components);
        return this;
    }