Creates a Map containing all properties (and their values) for a given
entity

@param entity
@param m
@return
487288
public Map<String, Object> createNodeProperties(Object entity, EntityMetadata m)
    {
        Map<String, Object> props = new HashMap<String, Object>();

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

        EntityType entityType = metaModel.entity(m.getEntityClazz());

        // Iterate over entity attributes
        Set<Attribute> attributes = entityType.getSingularAttributes();
        for (Attribute attribute : attributes)
        {
            Field field = (Field) attribute.getJavaMember();

            // Set Node level properties
            if (!attribute.isCollection() && !attribute.isAssociation())
            {

                String columnName = ((AbstractAttribute) attribute).getJPAColumnName();
                Object value = PropertyAccessorHelper.getObject(entity, field);
                if (value != null)
                {
                    props.put(columnName, toNeo4JProperty(value));
                }
            }
        }
        return props;
    }
70778
final void map(D6Model mModelObj, PreparedStatement preparedStatement) throws D6Exception {

        log("#map obj=" + mModelObj);

        final Set<String> primaryKeyColumnNameSet = getPrimaryColumnNames();

        // index starts from 1
        int parameterIndex = 1;

        final List<String> columnNameList = new ArrayList<String>(primaryKeyColumnNameSet);

        // scan column by column
        for (String columnName : columnNameList) {

            final D6ModelClassFieldInfo fieldInfo = getFieldInfo(columnName);

            final boolean isNullable = fieldInfo.isNullable;

            final Field field = fieldInfo.field;
            final String fieldName = field.getName();

            final Class<?> type = field.getType();

            Object fieldValue = null;

            try {
                fieldValue = field.get(mModelObj);
            } catch (IllegalArgumentException e) {
                throw new D6Exception(e);
            } catch (IllegalAccessException e) {
                throw new D6Exception(e);
            }

            //
            if (fieldValue == null && isNullable == false) {
                // In case found the null-value column,
                // even though this item is NOT NULL
                throw new D6Exception("D6Error the model object field '" + fieldName + "'(column name is " + columnName + ") should not null." + "Because of constraint of table definition.");
            }

            try {

                log("#map idx=" + parameterIndex + " " + columnName + "=" + fieldValue + " (" + type + ")");

                setValue(parameterIndex, preparedStatement, type, fieldValue);

            } catch (Exception e) {
                throw new D6Exception(e);
            }

            parameterIndex++;

        }// end for (String columnName : columnNameList) {

    }
893674
public static void fill(Object entity) {
        final Class<?> entityClass = entity.getClass();

        if (N.isEntity(entityClass) == false) {
            throw new IllegalArgumentException(entityClass.getCanonicalName() + " is not a valid entity class with property getter/setter method");
        }

        Type<Object> type = null;
        Class<?> parameterClass = null;
        Object propValue = null;

        for (Method method : ClassUtil.getPropSetMethodList(entityClass).values()) {
            parameterClass = method.getParameterTypes()[0];
            type = N.typeOf(parameterClass);

            if (String.class.equals(parameterClass)) {
                propValue = N.uuid().substring(0, 16);
            } else if (boolean.class.equals(parameterClass) || Boolean.class.equals(parameterClass)) {
                propValue = RAND.nextInt() % 2 == 0 ? false : true;
            } else if (char.class.equals(parameterClass) || Character.class.equals(parameterClass)) {
                propValue = (char) ('a' + RAND.nextInt() % 26);
            } else if (int.class.equals(parameterClass) || Integer.class.equals(parameterClass)) {
                propValue = RAND.nextInt();
            } else if (long.class.equals(parameterClass) || Long.class.equals(parameterClass)) {
                propValue = RAND.nextLong();
            } else if (float.class.equals(parameterClass) || Float.class.equals(parameterClass)) {
                propValue = RAND.nextFloat();
            } else if (double.class.equals(parameterClass) || Double.class.equals(parameterClass)) {
                propValue = RAND.nextDouble();
            } else if (byte.class.equals(parameterClass) || Byte.class.equals(parameterClass)) {
                propValue = Integer.valueOf(RAND.nextInt()).byteValue();
            } else if (short.class.equals(parameterClass) || Short.class.equals(parameterClass)) {
                propValue = Integer.valueOf(RAND.nextInt()).shortValue();
            } else if (Number.class.isAssignableFrom(parameterClass)) {
                propValue = type.valueOf(String.valueOf(RAND.nextInt()));
            } else if (java.util.Date.class.isAssignableFrom(parameterClass) || Calendar.class.isAssignableFrom(parameterClass)) {
                propValue = type.valueOf(String.valueOf(System.currentTimeMillis()));
            } else if (N.isEntity(parameterClass)) {
                propValue = fill(parameterClass);
            } else {
                propValue = type.defaultValue();
            }

            ClassUtil.setPropValue(entity, method, propValue);
        }
    }
644103
public ApiResponse createEntity(Map<String, Object> properties) {
        assertValidApplicationId();
        if (isEmpty(properties.get("type"))) {
            throw new IllegalArgumentException("Missing entity type");
        }
        ApiResponse response = apiRequest(HttpMethod.POST, null, properties,
                organizationId, applicationId, properties.get("type").toString());
        return response;
    }
221433
private Object getEntityWithAssociationFromNode(EntityMetadata m, Node node)
    {
        Map<String, Object> relationMap = new HashMap<String, Object>();

        /**
         * Map containing Node ID as key and Entity object as value. Helps cache
         * entity objects found earlier for faster lookup and prevents repeated
         * processing
         */
        Map<Long, Object> nodeIdToEntityMap = new HashMap<Long, Object>();

        Object entity = mapper.getEntityFromNode(node, m);

        nodeIdToEntityMap.put(node.getId(), entity);
        populateRelations(m, entity, relationMap, node, nodeIdToEntityMap);

        nodeIdToEntityMap.clear();

        if (!relationMap.isEmpty() && entity != null)
        {
            return new EnhanceEntity(entity, PropertyAccessorHelper.getId(entity, m), relationMap);
        }
        else
        {
            return entity;
        }

    }
242471
@Override
    public MapMessage createMapMessage() throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createMapMessage");

        MapMessage mapMessage = null;

        try {
            mapMessage = jmsSession.createMapMessage();
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createMapMessage", new Object[] { mapMessage });
        }

        return mapMessage;

    }
6518
public Entity wrap(Entity entity){
		if(null == entity) {
			return null;
		}
		
		final Entity wrapedEntity = new Entity();
		
		//wrap table name
		wrapedEntity.setTableName(wrap(entity.getTableName()));
		
		//wrap fields
		for (Entry<String, Object> entry : entity.entrySet()) {
			wrapedEntity.set(wrap(entry.getKey()), entry.getValue());
		}
		
		return wrapedEntity;
	}
419925
public Map<String, Object> dehydrate(Entity entity) {
    LOG.trace("Dehydrating entity {}", entity);
    Map<String, Object> dehydratedEntity = newHashMap();
    EntityType entityType = entity.getEntityType();

    entityType
        .getAtomicAttributes()
        .forEach(
            attribute -> {
              // Only dehydrate if the attribute is NOT computed
              if (!attribute.hasExpression()) {
                String name = attribute.getName();
                AttributeType type = attribute.getDataType();

                dehydratedEntity.put(name, getValueBasedOnType(entity, name, type));
              }
            });

    return dehydratedEntity;
  }
755739
@Override
    protected List<Object> populateEntities(EntityMetadata m, Client client)
    {
        return onQuery(m, client);
    }
1253851
public Map<String, Object> createRelationshipProperties(EntityMetadata entityMetadata,
            EntityMetadata targetEntityMetadata, Object relationshipEntity)
    {
        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                entityMetadata.getPersistenceUnit());
        EntityType entityType = metaModel.entity(relationshipEntity.getClass());
        Map<String, Object> relationshipProperties = new HashMap<String, Object>();

        Set<Attribute> attributes = entityType.getSingularAttributes();
        for (Attribute attribute : attributes)
        {
            Field f = (Field) attribute.getJavaMember();
            if (!f.getType().equals(entityMetadata.getEntityClazz())
                    && !f.getType().equals(targetEntityMetadata.getEntityClazz()))
            {
                String relPropertyName = ((AbstractAttribute) attribute).getJPAColumnName();
                Object value = PropertyAccessorHelper.getObject(relationshipEntity, f);
                relationshipProperties.put(relPropertyName, toNeo4JProperty(value));
            }
        }
        return relationshipProperties;
    }
160995
public static String buildEqualsWhere(Entity entity, List<Object> paramValues) {
		if (null == entity || entity.isEmpty()) {
			return StrUtil.EMPTY;
		}

		final StringBuilder sb = new StringBuilder(" WHERE ");
		boolean isNotFirst = false;
		for (Entry<String, Object> entry : entity.entrySet()) {
			if (isNotFirst) {
				sb.append(" and ");
			} else {
				isNotFirst = true;
			}
			sb.append("`").append(entry.getKey()).append("`").append(" = ?");
			paramValues.add(entry.getValue());
		}

		return sb.toString();
	}
728134
public static <T> String writeObjectToString(final T entity) {
        ByteArrayOutputStream destination = new ByteArrayOutputStream();
        writeObject(entity, destination, null);
        return destination.toString();
    }
26627
public static Map<String, AttributeValueUpdate> toUpdateItem(final Object entity) {
        return toUpdateItem(entity, NamingPolicy.LOWER_CAMEL_CASE);
    }
71764
public List find(String nativeQuery, List<String> relations, EntityMetadata m)
    {
        List entities = new ArrayList();

        s = getStatelessSession();

        SQLQuery q = s.createSQLQuery(nativeQuery);
        q.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);

        List result = q.list();

        try
        {
            MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                    m.getPersistenceUnit());

            EntityType entityType = metaModel.entity(m.getEntityClazz());

            List<AbstractManagedType> subManagedType = ((AbstractManagedType) entityType).getSubManagedType();
            for (Object o : result)
            {
                Map<String, Object> relationValue = null;
                Object entity = null;
                EntityMetadata subEntityMetadata = null;
                if (!subManagedType.isEmpty())
                {
                    for (AbstractManagedType subEntity : subManagedType)
                    {
                        String discColumn = subEntity.getDiscriminatorColumn();
                        String disColValue = subEntity.getDiscriminatorValue();
                        Object value = ((Map<String, Object>) o).get(discColumn);
                        if (value != null && value.toString().equals(disColValue))
                        {
                            subEntityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                                    subEntity.getJavaType());
                            break;
                        }
                    }
                    entity = instantiateEntity(subEntityMetadata.getEntityClazz(), entity);
                    relationValue = HibernateUtils.getTranslatedObject(kunderaMetadata, entity,
                            (Map<String, Object>) o, m);

                }
                else
                {
                    entity = instantiateEntity(m.getEntityClazz(), entity);
                    relationValue = HibernateUtils.getTranslatedObject(kunderaMetadata, entity,
                            (Map<String, Object>) o, m);
                }

                if (relationValue != null && !relationValue.isEmpty())
                {
                    entity = new EnhanceEntity(entity, PropertyAccessorHelper.getId(entity, m), relationValue);
                }
                entities.add(entity);
            }
            return entities;
        }
        catch (Exception e)
        {
            if (e.getMessage().equals("Can not be translated into entity."))
            {
                return result;
            }
            throw new EntityReaderException(e);
        }
    }
286782
public Map<String, Class<?>> getEntityNameToClassMap()
    {
        if (entityNameToClassMap == null)
        {
            entityNameToClassMap = new HashMap<String, Class<?>>();
        }
        return entityNameToClassMap;
    }
892220
@Override
    public T create(T entity) {
        EntityManager entityManager = getEntityManager();
        entityManager.persist(entity);
        return entity;
    }
638789
private void generateDaoPart(M2MEntity entity) {
		String daoClassName = entity.daoName.simpleName();

		String daoPackageName = entity.daoName.packageName();
		String entityPackageName = entity.getPackageName();
		String generatedDaoClassName = "Generated" + daoClassName;

		AnnotationProcessorUtilis.infoOnGeneratedClasses(BindDaoMany2Many.class, daoPackageName, generatedDaoClassName);
		// @formatter:off
		classBuilder = TypeSpec.interfaceBuilder(generatedDaoClassName).addModifiers(Modifier.PUBLIC)
				.addAnnotation(AnnotationSpec.builder(BindDao.class)
						.addMember("value", "$T.class", TypeUtility.className(entityPackageName, entity.name)).build())
				.addAnnotation(AnnotationSpec.builder(BindGeneratedDao.class)
						.addMember("dao", "$T.class", entity.daoName).build())
				.addAnnotation(AnnotationSpec.builder(BindDaoMany2Many.class)
						.addMember("entity1", "$T.class", entity.entity1Name)
						.addMember("entity2", "$T.class", entity.entity2Name).build())
				.addSuperinterface(entity.daoName);
		// @formatter:on

		JavadocUtility.generateJavadocGeneratedBy(classBuilder);

		if (entity.generateMethods) {
			generateSelects(entity, entityPackageName);
			generateDeletes(entity, entityPackageName);
			generateInsert(entity, entityPackageName);
		}

		TypeSpec typeSpec = classBuilder.build();

		try {
			JavaWriterHelper.writeJava2File(filer, daoPackageName, typeSpec);
		} catch (IOException e) {
			throw new KriptonRuntimeException(e);
		}

		GeneratedTypeElement daoPartElement = new GeneratedTypeElement(daoPackageName, classBuilder.build(), null,
				null);
		daoResult.add(daoPartElement);
	}