DefaultJpaDatastore.java 文件源码

java
阅读 37 收藏 0 点赞 0 评论 0

项目:holon-datastore-jpa 作者:
/**
 * Set the entity id values of given <code>entity</code> instance to be returned as an {@link OperationResult}.
 * @param result OperationResult in which to set the ids
 * @param entityManager EntityManager
 * @param set Entity bean property set
 * @param entity Entity class
 * @param instance Entity instance
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void setInsertedIds(OperationResult.Builder result, EntityManager entityManager,
        BeanPropertySet<Object> set, Class<?> entity, Object instance, boolean bringBackGeneratedIds,
        PropertyBox propertyBox) {
    try {
        getIds(entityManager, set, entity).forEach(p -> {
            Object keyValue = set.read(p, instance);
            result.withInsertedKey(p, keyValue);
            if (bringBackGeneratedIds && keyValue != null) {
                // set in propertybox
                Property property = getPropertyForPath(p, propertyBox);
                if (property != null) {
                    propertyBox.setValue(property, keyValue);
                }
            }
        });
    } catch (Exception e) {
        LOGGER.warn("Failed to obtain entity id(s) value", e);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号