package jp.agentec.sinaburocast.service; import java.util.ArrayList; import java.util.List; import javax.annotation.Generated; import jp.agentec.sinaburocast.dto.TestDto; import jp.agentec.sinaburocast.dxo.TestDxo; import jp.agentec.sinaburocast.entity.Test; import org.seasar.extension.jdbc.where.SimpleWhere; import org.seasar.framework.container.annotation.tiger.Component; import org.seasar.framework.container.annotation.tiger.InstanceType; /** * {@link Test}のサービスクラスです。 * */ @Component(instance=InstanceType.SINGLETON) @Generated(value = {"S2JDBC-Gen 2.4.40", "org.seasar.extension.jdbc.gen.internal.model.ServiceModelFactoryImpl"}, date = "2010/04/20 19:06:21") public class TestService extends AbstractService<Test> { private static final String ID_SEQ_NAME = "test_id_seq"; public TestDxo testDxo; /** * IDを発行して、登録する。 * */ public int insert(Test test, String insId) { test.testId = getSeqNextVal(Integer.class, ID_SEQ_NAME); return super.insert(test, insId); } /** * IDから検索する。 * * @param contentId * @return */ public Test findById(Integer testId) { return select().id(testId).getSingleResult(); } /** * IDから検索する(DTOで返却)。 * * @param contentId * @return */ public TestDto findDtoById(Integer testId) { Test test = select().id(testId).getSingleResult(); return testDxo.convert(test); } /** * 名前でLIKE検索 * * @param testName * @return */ public List<Test> findTestListByName(String testName) { return select().innerJoin("testType").where(new SimpleWhere().like("testName", "%" + testName + "%")).getResultList(); } /** * 名前でLIKE検索(DTO返却) * * @param testName * @return */ public List<TestDto> findTestDtoListByName(String testName) { List<Test> testList = select().innerJoin("testType").where(new SimpleWhere().like("testName", "%" + testName + "%")).getResultList(); List<TestDto> testDtoList = new ArrayList<TestDto>(); testDxo.convert(testList, testDtoList); return testDtoList; } /** * 名前でLIKE検索(DTO返却:SQL実行) * * @param testName * @return */ public List<TestDto> findTestDtoListByNameSql(String testName) { return jdbcManager.selectBySqlFile(TestDto.class, "jp/agentec/sinaburocast/service/findTestDtoListByNameSql.sql", "%" + testName + "%").getResultList(); } /** * TestTypeIdで検索 * * @param testTypeId * @return */ public List<Test> findByTestTypeId(Integer testTypeId) { return select().where(new SimpleWhere().eq("testTypeId", testTypeId)).getResultList(); } /** * 子を含めて返す。 * * @param testId * @return */ public List<Test> findTestWithChild(Integer testId) { return select().innerJoin("childList").where(new SimpleWhere().eq("testId", testId)).getResultList(); } }