コード例 #1
0
  public List<Cart> getListAvailable() throws Exception {
    Session session = HibernateUtil.getInstace().getSessionFactory().openSession();
    session.beginTransaction();

    String subQuery =
        "(SELECT "
            + DBContract.CART_COLUMN_ID
            + " FROM "
            + DBContract.PRODUCTIONORDER_TABLE
            + " WHERE "
            + DBContract.ORDERSTATE_COLUMN_ID
            + " != 4)";

    String query =
        "SELECT "
            + DBContract.CART_COLUMN_ID
            + ","
            + DBContract.CART_COLUMN_NAME
            + ","
            + DBContract.CART_COLUMN_TABLETMAC
            + " FROM "
            + DBContract.CART_TABLE
            + " WHERE "
            + DBContract.CART_COLUMN_ID
            + " NOT IN "
            + subQuery;

    List<Cart> listMyModel = session.createSQLQuery(query).addEntity(Cart.class).list();
    session.close();

    return listMyModel;
  }
コード例 #2
0
 @Override
 public List<MyModel> getListAll() throws Exception {
   Session session = HibernateUtil.getInstace().getSessionFactory().openSession();
   session.beginTransaction();
   List<MyModel> listMyModel = session.createCriteria(Cart.class).list();
   session.close();
   return listMyModel;
 }
コード例 #3
0
 @Override
 public MyModel getOne(final int id) throws Exception {
   Session session = HibernateUtil.getInstace().getSessionFactory().openSession();
   session.beginTransaction();
   MyModel myModel = (MyModel) session.get(Cart.class, id);
   session.close();
   return myModel;
 }