Java Code Examples for io.jboot.db.model.JbootModel#copy()

The following examples show how to use io.jboot.db.model.JbootModel#copy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JbootServiceJoinerImpl.java    From jboot with Apache License 2.0 6 votes vote down vote up
/**
 * 添加关联数据到某个model中去,避免关联查询,提高性能。
 *
 * @param model
 * @param joinOnField
 * @param attrs
 */
@Override
public <M extends Model> M join(M model, String joinOnField, String[] attrs) {
    if (model == null)
        return model;
    Object id = model.get(joinOnField);
    if (id == null) {
        return model;
    }
    JbootModel m = joinById(id);
    if (m != null) {
        m = m.copy();
        m.keep(attrs);
        model.put(StrKit.firstCharToLowerCase(m.getClass().getSimpleName()), m);
    }
    return model;
}
 
Example 2
Source File: JbootServiceJoinerImpl.java    From jboot with Apache License 2.0 6 votes vote down vote up
/**
 * 添加关联数据到某个model中去,避免关联查询,提高性能。
 *
 * @param model
 * @param joinOnField
 * @param joinName
 * @param attrs
 */
@Override
public <M extends Model> M join(M model, String joinOnField, String joinName, String[] attrs) {
    if (model == null)
        return model;
    Object id = model.get(joinOnField);
    if (id == null) {
        return model;
    }
    JbootModel m = joinById(id);
    if (m != null) {
        m = m.copy();
        m.keep(attrs);
        model.put(joinName, m);
    }
    return model;
}