All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sf.core.LazyLoadUtils Maven / Gradle / Ivy

The newest version!
package sf.core;

import sf.database.dao.DBClient;
import sf.database.dao.DBContext;
import sf.database.jdbc.sql.Crud;

public class LazyLoadUtils {
    /**
     * 加载子对象
     * @param client    client
     * @param object    对象
     * @param fieldName 级联字段
     */
    public static void loadCascadeObject(DBClient client, DBContext context, DBObject object, String fieldName) {
        if (context != null) {
            context.setUseLazyLoad(false);
            client.useContext(context);
        }
        client.executeFunc(connection -> Crud.getInstance().getCrudModel().fetchLinks(connection, object, fieldName));
    }

    /**
     * 设置延迟加载信息
     * @param object  对象
     * @param client  db对象
     * @param context 上下文 可为null
     */
    public static void setLazyLoadContext(DBObject object, DBClient client, DBContext context) {
        object.lazyload = new LazyLoadContext(client, context);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy