获得主键where子句，包含where关键字。会自动处理软删除条件

@param clazz
@throws NoKeyColumnAnnotationException
5336
public static String getKeysWhereSQL(Class<?> clazz) 
			throws NoKeyColumnAnnotationException {
		List<Field> keyFields = DOInfoReader.getKeyColumns(clazz);
		String where = joinWhere(keyFields, "AND");
		return autoSetSoftDeleted("WHERE " + where, clazz);
	}
695242
public static <T> String getKeysWhereSQL(T t, List<Object> keyValues) 
	    throws NoKeyColumnAnnotationException, NullKeyValueException {
		
		List<Field> keyFields = DOInfoReader.getKeyColumns(t.getClass());
		
		List<Object> _keyValues = new ArrayList<Object>();
		String where = joinWhereAndGetValue(keyFields, "AND", _keyValues, t);
		
		// 检查主键不允许为null
		for(Object value : keyValues) {
			if(value == null) {
				throw new NullKeyValueException();
			}
		}
		
		if(keyValues != null) {
			keyValues.addAll(_keyValues);
		}
		
		return autoSetSoftDeleted("WHERE " + where, t.getClass());
	}
947965
public void clearTransition (Class<?> clazz, final String name)
        throws PersistenceException
    {
        final String cname = clazz.getName();
        executeUpdate(new Operation<Void>() {
            public Void invoke (Connection conn, DatabaseLiaison liaison)
                throws SQLException, PersistenceException
            {
                PreparedStatement stmt = null;
                try {
                    stmt = conn.prepareStatement(
                        " delete from " + liaison.tableSQL("TRANSITIONS") +
                        "       where " + liaison.columnSQL("CLASS") + "=? " +
                        "         and " + liaison.columnSQL("NAME") + "=?");
                    stmt.setString(1, cname);
                    stmt.setString(2, name);
                    stmt.executeUpdate(); // we don't care if it worked or not

                } finally {
                    JDBCUtil.close(stmt);
                }
                return null;
            }
        });
    }
1301878
@Override
    public Object[] findIdsByColumn(String schemaName, String tableName, String pKeyName, String columnName,
            Object columnValue, Class entityClazz)
    {
        List foreignKeys = new ArrayList();
        HttpResponse response = null;
        EntityMetadata m = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClazz);
        try
        {
            String q = "key=" + CouchDBUtils.appendQuotes(columnValue);
            URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(),
                    CouchDBConstants.URL_SEPARATOR + schemaName.toLowerCase() + CouchDBConstants.URL_SEPARATOR
                            + CouchDBConstants.DESIGN + tableName + CouchDBConstants.VIEW + columnName, q, null);
            HttpGet get = new HttpGet(uri);
            get.addHeader("Accept", "application/json");
            response = httpClient.execute(get);

            InputStream content = response.getEntity().getContent();
            Reader reader = new InputStreamReader(content);
            JsonObject json = gson.fromJson(reader, JsonObject.class);

            JsonElement jsonElement = json.get("rows");
            if (jsonElement == null)
            {
                return foreignKeys.toArray();
            }
            JsonArray array = jsonElement.getAsJsonArray();
            for (JsonElement element : array)
            {
                JsonElement value = element.getAsJsonObject().get("value").getAsJsonObject().get(pKeyName);
                if (value != null)
                {
                    foreignKeys.add(PropertyAccessorHelper.fromSourceToTargetClass(m.getIdAttribute()
                            .getBindableJavaType(), String.class, value.getAsString()));
                }
            }
        }
        catch (Exception e)
        {
            log.error("Error while fetching ids for column where column name is" + columnName
                    + " and column value is {} , Caused by {}.", columnValue, e);
            throw new KunderaException(e);
        }
        finally
        {
            closeContent(response);
        }
        return foreignKeys.toArray();
    }
1307413
public static void classNotConfigured(Class<?> clazz){
		throw new MappingNotFoundException(MSG.INSTANCE.message(Constants.mappingNotFoundException1, clazz.getSimpleName()));
	}
1231877
private static void onBind(Class clazz)
    {

        if (((MetamodelImpl) em.getMetamodel()).getEntityMetadataMap().isEmpty())
        {

            EntityMetadata metadata = new EntityMetadata(clazz);
            metadata.setPersistenceUnit(getPersistenceUnit());

            setSchemaAndPU(clazz, metadata);

            new TableProcessor(em.getEntityManagerFactory().getProperties(),
                    ((EntityManagerFactoryImpl) em.getEntityManagerFactory()).getKunderaMetadataInstance())
                            .process(clazz, metadata);

            KunderaMetadata kunderaMetadata = ((EntityManagerFactoryImpl) em.getEntityManagerFactory())
                    .getKunderaMetadataInstance();

            new IndexProcessor(kunderaMetadata).process(clazz, metadata);

            ApplicationMetadata appMetadata = kunderaMetadata.getApplicationMetadata();

            ((MetamodelImpl) em.getMetamodel()).addEntityMetadata(clazz, metadata);
            ((MetamodelImpl) em.getMetamodel()).addEntityNameToClassMapping(clazz.getSimpleName(), clazz);
            appMetadata.getMetamodelMap().put(getPersistenceUnit(), em.getMetamodel());

            Map<String, List<String>> clazzToPuMap = new HashMap<String, List<String>>();
            List<String> persistenceUnits = new ArrayList<String>();
            persistenceUnits.add(getPersistenceUnit());
            clazzToPuMap.put(clazz.getName(), persistenceUnits);
            appMetadata.setClazzToPuMap(clazzToPuMap);
            new SchemaConfiguration(em.getEntityManagerFactory().getProperties(), kunderaMetadata, getPersistenceUnit())
                    .configure();

        }

    }
909988
@Override
    public <E> List<E> getColumnsById(String schemaName, String tableName, String pKeyColumnName,
            String inverseJoinColumnName, Object pKeyColumnValue, Class columnJavaType)
    {
        List<E> foreignKeys = new ArrayList<E>();

        URI uri = null;
        HttpResponse response = null;
        try
        {
            String q = "key=" + CouchDBUtils.appendQuotes(pKeyColumnValue);
            uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(),
                    CouchDBConstants.URL_SEPARATOR + schemaName.toLowerCase() + CouchDBConstants.URL_SEPARATOR
                            + CouchDBConstants.DESIGN + tableName + CouchDBConstants.VIEW + pKeyColumnName, q, null);
            HttpGet get = new HttpGet(uri);
            get.addHeader("Accept", "application/json");
            response = httpClient.execute(get);

            InputStream content = response.getEntity().getContent();
            Reader reader = new InputStreamReader(content);
            JsonObject json = gson.fromJson(reader, JsonObject.class);

            JsonElement jsonElement = json.get("rows");

            if (jsonElement == null)
            {
                return foreignKeys;
            }

            JsonArray array = jsonElement.getAsJsonArray();
            for (JsonElement element : array)
            {
                JsonElement value = element.getAsJsonObject().get("value").getAsJsonObject().get(inverseJoinColumnName);
                if (value != null)
                {
                    foreignKeys.add((E) PropertyAccessorHelper.fromSourceToTargetClass(columnJavaType, String.class,
                            value.getAsString()));
                }
            }
        }
        catch (Exception e)
        {
            log.error("Error while fetching column by id {}, Caused by {}.", pKeyColumnValue, e);
            throw new KunderaException(e);
        }
        finally
        {
            closeContent(response);
        }
        return foreignKeys;
    }
1158913
@Override
    public <E> List<E> getColumnsById(String schemaName, String joinTableName, String joinColumnName,
            String inverseJoinColumnName, Object parentId, Class columnJavaType)
    {
        StringBuffer sqlQuery = new StringBuffer();
        sqlQuery.append("SELECT ").append(inverseJoinColumnName).append(" FROM ")
                .append(getFromClause(schemaName, joinTableName)).append(" WHERE ").append(joinColumnName).append("='")
                .append(parentId).append("'");

        Session s = getSession();

        SQLQuery query = s.createSQLQuery(sqlQuery.toString());

        List<E> foreignKeys = new ArrayList<E>();

        foreignKeys = query.list();

        return foreignKeys;
    }
1019981
@Override
    public Object[] findIdsByColumn(String schemaName, String tableName, String pKeyName, String columnName,
            Object columnValue, Class entityClazz)
    {
        EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClazz);

        List<Object> primaryKeys = new ArrayList<Object>();

        DBCollection dbCollection = mongoDb.getCollection(tableName);
        BasicDBObject query = new BasicDBObject();

        query.put(columnName, MongoDBUtils.populateValue(columnValue, columnValue.getClass()));

        DBCursor cursor = dbCollection.find(query);
        KunderaCoreUtils.printQuery("Find id by column:" + query, showQuery);
        DBObject fetchedDocument = null;

        while (cursor.hasNext())
        {
            fetchedDocument = cursor.next();
            Object primaryKey = fetchedDocument.get(pKeyName);
            primaryKey = MongoDBUtils.getTranslatedObject(primaryKey, primaryKey.getClass(), metadata.getIdAttribute()
                    .getJavaType());
            primaryKeys.add(primaryKey);
        }

        if (primaryKeys != null && !primaryKeys.isEmpty())
        {
            return primaryKeys.toArray(new Object[0]);
        }
        return null;

    }
1042822
@Override
    public <E> List<E> getColumnsById(String schemaName, String joinTableName, String joinColumnName,
            String inverseJoinColumnName, Object parentId, Class columnJavaType)
    {
        return handler.getForeignKeysFromJoinTable(schemaName, joinTableName, parentId, inverseJoinColumnName);
    }
1144135
@Override
    public Object[] findIdsByColumn(String schemaName, String tableName, String pKeyName, String columnName,
            Object columnValue, Class entityClazz)
    {
        Object connection = null;

        try
        {
            connection = getConnection();
            String valueAsStr = PropertyAccessorHelper.getString(columnValue);

            Set<String> results = null;

            if (resource != null && resource.isActive())
            {
                Response response = ((Transaction) connection).zrangeByScore(getHashKey(tableName, valueAsStr),
                        getDouble(valueAsStr), getDouble(valueAsStr));
                // ((Transaction) connection).exec();
                ((RedisTransaction) resource).onExecute(((Transaction) connection));

                results = (Set<String>) response.get();
            }
            else
            {
                results = ((Jedis) connection).zrangeByScore(getHashKey(tableName, valueAsStr), getDouble(valueAsStr),
                        getDouble(valueAsStr));

            }

            List returnResults = new ArrayList();
            returnResults = fetchColumn(pKeyName, connection, returnResults, results);
            if (returnResults != null)
            {

                return returnResults.toArray(new Object[0]);
            }

        }
        finally
        {
            onCleanup(connection);
        }

        return null;
    }
690501
@Nullable
    static ColumnMetadata buildColumnMetadata(@NotNull PropertyDescriptor propertyDescriptor,
                                              @NotNull Class clazz,
                                              @NotNull CassandraClient cassandraClient,
                                              @NotNull TableMetadata tableMetadata) {

        try {
            Field field = clazz.getDeclaredField(propertyDescriptor.getName());

            if (field.isAnnotationPresent(Column.class)) {

                Column columnAnnotation = field.getDeclaredAnnotation(Column.class);

                String columnName = getColumnName(propertyDescriptor, columnAnnotation);

                ColumnMetadata columnMetadata = new BaseColumnMetadata(propertyDescriptor, clazz, field.getType(), columnName, tableMetadata.getColumn(columnName).getType());

                if (field.isAnnotationPresent(Enumerated.class)) {
                    Enumerated enumeratedAnnotation = field.getDeclaredAnnotation(Enumerated.class);

                    columnMetadata = new EnumeratedMetadata(columnMetadata, enumeratedAnnotation.enumType());
                }
                if (field.isAnnotationPresent(UDTColumn.class)) {
                    UDTColumn udtColumnAnnotation = field.getDeclaredAnnotation(UDTColumn.class);

                    Class udtClassType = udtColumnAnnotation.udtType();

                    if (udtClassType.isAnnotationPresent(UDT.class)) {
                        UDT declaredAnnotation = (UDT) udtClassType.getDeclaredAnnotation(UDT.class);

                        String keyspace = StringUtils.isEmpty(declaredAnnotation.keyspace()) ? cassandraClient.getDefaultKeyspace() : declaredAnnotation.keyspace();

                        UserType userType = cassandraClient.getKeyspaceMetadata(keyspace)
                                                           .getUserType(declaredAnnotation.name());

                        Verify.verifyNotNull(userType);

                        columnMetadata = new UserDataTypeMetadata(udtColumnAnnotation.udtType(), userType, columnMetadata);
                    }


                }

                if (field.isAnnotationPresent(PrimaryKey.class)) {
                    PrimaryKey primaryKeyAnnotation = field.getDeclaredAnnotation(PrimaryKey.class);
                    columnMetadata = new PrimaryKeyMetadata(columnMetadata, primaryKeyAnnotation.order(), primaryKeyAnnotation.isPartitionKey());
                }


                return columnMetadata;
            }
        } catch (NoSuchFieldException e) {
            if (!StringUtils.equals("class", propertyDescriptor.getDisplayName())) {
                LOGGER.warn("Can't get field", e);
            }
        }

        return null;
    }
1134616
protected List<String> getNonPrimaryKeyColumns(String tableName) {
        List<String> columns = getAllColumns(tableName);
        columns.removeAll(getPrimaryKeys(tableName));
        return columns;
    }
168717
public static List<TableColumnInfo> create(@NotNull final Class<?> clasz, @NotNull final Locale locale) {

        Contract.requireArgNotNull("clasz", clasz);
        Contract.requireArgNotNull("locale", locale);

        final List<TableColumnInfo> list = new ArrayList<TableColumnInfo>();
        final Field[] fields = clasz.getDeclaredFields();
        for (int i = 0; i < fields.length; i++) {
            final TableColumnInfo tableColumnInfo = create(fields[i], locale);
            if (tableColumnInfo != null) {
                list.add(tableColumnInfo);
            }
        }
        Collections.sort(list);
        return list;
    }
1091101
static final <T> TableMap<T> of(Class<T> clazz) {
        final TableMap<T> annotations = new TableMap<T>(clazz);
        annotations.putAll(clazz);
        return annotations;
    }
1119958
protected static SQLEnum value(Class<? extends SQLEnum> clazz,String value) {
		if (value == null) {
			return null;
		}
		
		value=value.trim();
		
		if (valuesCache.containsKey(clazz)){
			Map<String,SQLEnum> map2=valuesCache.get(clazz);
			
			if (map2.containsKey(value)){
				return map2.get(value);
			}
		}

		return null;
	}
805766
public void containsColumn(@NullableDecl Object columnKey) {
    check("columnKeySet()").that(actual().columnKeySet()).contains(columnKey);
  }