使字段无效
/** n o w j a v a . c o m **/ //package com.nowjava; import java.lang.reflect.Field; public class Main { public static <E> void nullifyField(final E entity, final Field field) throws Exception { if (field.getType().isEnum() || field.getType().isPrimitive()) { return; } field.setAccessible(true); field.set(entity, null); }/** 来 自 N o w J a v a . c o m**/ }