View Javadoc
1   /*
2    *    Copyright 2009-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.submitted.primitive_result_type;
17  
18  import java.math.BigDecimal;
19  import java.util.List;
20  
21  import org.apache.ibatis.session.SqlSession;
22  
23  public class ProductDAO {
24  
25    public static List<Integer> selectProductCodes() {
26      try (SqlSession session = IbatisConfig.getSession()) {
27        ProductMapper productMapper = session.getMapper(ProductMapper.class);
28        return productMapper.selectProductCodes();
29      } catch (Exception e) {
30        throw new RuntimeException(e);
31      }
32    }
33  
34    public static List<Long> selectProductCodesL() {
35      try (SqlSession session = IbatisConfig.getSession()) {
36        ProductMapper productMapper = session.getMapper(ProductMapper.class);
37        return productMapper.selectProductCodesL();
38      } catch (Exception e) {
39        throw new RuntimeException(e);
40      }
41    }
42  
43    public static List<BigDecimal> selectProductCodesB() {
44      try (SqlSession session = IbatisConfig.getSession()) {
45        ProductMapper productMapper = session.getMapper(ProductMapper.class);
46        return productMapper.selectProductCodesB();
47      } catch (Exception e) {
48        throw new RuntimeException(e);
49      }
50    }
51  
52    public static List<Product> selectAllProducts() {
53      try (SqlSession session = IbatisConfig.getSession()) {
54        ProductMapper productMapper = session.getMapper(ProductMapper.class);
55        return productMapper.selectAllProducts();
56      } catch (Exception e) {
57        throw new RuntimeException(e);
58      }
59    }
60  
61    private ProductDAO() {
62    }
63  
64  }