com.landawn.abacus.jdbc.dao.CrudJoinEntityHelperL Maven / Gradle / Ivy
/*
* Copyright (c) 2021, Haiyang Li.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.landawn.abacus.jdbc.dao;
import java.sql.SQLException;
import java.util.Collection;
import com.landawn.abacus.annotation.Beta;
import com.landawn.abacus.exception.DuplicatedResultException;
import com.landawn.abacus.util.SQLBuilder;
import com.landawn.abacus.util.u.Optional;
public interface CrudJoinEntityHelperL> extends CrudJoinEntityHelper {
/**
*
* @param id
* @param joinEntitiesToLoad
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default Optional get(final long id, final Class> joinEntitiesToLoad) throws DuplicatedResultException, SQLException {
return Optional.ofNullable(gett(id, joinEntitiesToLoad));
}
/**
*
* @param id
* @param includeAllJoinEntities
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default Optional get(final long id, final boolean includeAllJoinEntities) throws DuplicatedResultException, SQLException {
return Optional.ofNullable(gett(id, includeAllJoinEntities));
}
/**
*
* @param id
* @param selectPropNames all properties(columns) will be selected, excluding the properties of joining entities, if the specified {@code selectPropNames} is {@code null}.
* @param joinEntitiesToLoad
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default Optional get(final long id, final Collection selectPropNames, final Class> joinEntitiesToLoad)
throws DuplicatedResultException, SQLException {
return Optional.ofNullable(gett(id, selectPropNames, joinEntitiesToLoad));
}
/**
*
* @param id
* @param selectPropNames all properties(columns) will be selected, excluding the properties of joining entities, if the specified {@code selectPropNames} is {@code null}.
* @param joinEntitiesToLoad
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default Optional get(final long id, final Collection selectPropNames, final Collection> joinEntitiesToLoad)
throws DuplicatedResultException, SQLException {
return Optional.ofNullable(gett(id, selectPropNames, joinEntitiesToLoad));
}
/**
*
* @param id
* @param selectPropNames all properties(columns) will be selected, excluding the properties of joining entities, if the specified {@code selectPropNames} is {@code null}.
* @param includeAllJoinEntities
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default Optional get(final long id, final Collection selectPropNames, final boolean includeAllJoinEntities)
throws DuplicatedResultException, SQLException {
return Optional.ofNullable(gett(id, selectPropNames, includeAllJoinEntities));
}
/**
*
* @param id
* @param joinEntitiesToLoad
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default T gett(final long id, final Class> joinEntitiesToLoad) throws DuplicatedResultException, SQLException {
final T result = DaoUtil.getCrudDao(this).gett(id);
if (result != null) {
loadJoinEntities(result, joinEntitiesToLoad);
}
return result;
}
/**
*
* @param id
* @param includeAllJoinEntities
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default T gett(final long id, final boolean includeAllJoinEntities) throws DuplicatedResultException, SQLException {
final T result = DaoUtil.getCrudDao(this).gett(id);
if (result != null && includeAllJoinEntities) {
loadAllJoinEntities(result);
}
return result;
}
/**
*
* @param id
* @param selectPropNames all properties(columns) will be selected, excluding the properties of joining entities, if the specified {@code selectPropNames} is {@code null}.
* @param joinEntitiesToLoad
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default T gett(final long id, final Collection selectPropNames, final Class> joinEntitiesToLoad) throws DuplicatedResultException, SQLException {
final T result = DaoUtil.getCrudDao(this).gett(id, selectPropNames);
if (result != null) {
loadJoinEntities(result, joinEntitiesToLoad);
}
return result;
}
/**
*
* @param id
* @param selectPropNames all properties(columns) will be selected, excluding the properties of joining entities, if the specified {@code selectPropNames} is {@code null}.
* @param joinEntitiesToLoad
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default T gett(final long id, final Collection selectPropNames, final Collection> joinEntitiesToLoad)
throws DuplicatedResultException, SQLException {
final T result = DaoUtil.getCrudDao(this).gett(id, selectPropNames);
if (result != null) {
for (final Class> joinEntityClass : joinEntitiesToLoad) {
loadJoinEntities(result, joinEntityClass);
}
}
return result;
}
/**
*
* @param id
* @param selectPropNames all properties(columns) will be selected, excluding the properties of joining entities, if the specified {@code selectPropNames} is {@code null}.
* @param includeAllJoinEntities
* @return
* @throws DuplicatedResultException if more than one record found by the specified {@code id} (or {@code condition}).
* @throws SQLException
*/
@Beta
default T gett(final long id, final Collection selectPropNames, final boolean includeAllJoinEntities)
throws DuplicatedResultException, SQLException {
final T result = DaoUtil.getCrudDao(this).gett(id, selectPropNames);
if (result != null && includeAllJoinEntities) {
loadAllJoinEntities(result);
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy