List of usage examples for org.hibernate.criterion Projections max
public static AggregateProjection max(String propertyName)
From source file:com.aes.dao.impl.CourseCategoryDaoImpl.java
@Override public int getNextId() { int nextNumber = 1; try {// w w w .ja va2s. c o m Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(CourseCategory.class) .setProjection(Projections.max("courseCategoryId")).uniqueResult()) + 1; if (nextInt == null) { return 1; } nextNumber = nextInt.intValue(); } catch (Exception e) { } return nextNumber; }
From source file:com.aes.dao.impl.CourseDaoImpl.java
@Override public int getNextId() { int nextNumber = 1; try {//w ww. ja v a2 s.com Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(Course.class) .setProjection(Projections.max("courseId")).uniqueResult()) + 1; if (nextInt == null) { return 1; } nextNumber = nextInt.intValue(); } catch (Exception e) { } return nextNumber; }
From source file:com.aes.dao.impl.CoursesAssignedDaoImpl.java
@Override public int getNextId() { int nextNumber = 1; try {/* w w w . j a v a 2 s . c o m*/ Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(CoursesAssigned.class) .setProjection(Projections.max("assignmentId")).uniqueResult()) + 1; if (nextInt == null) { return 1; } nextNumber = nextInt.intValue(); } catch (Exception e) { } return nextNumber; }
From source file:com.aes.dao.impl.ExamDaoImpl.java
@Override public int getNextId() { int nextNumber = 1; try {// w w w . j a va 2 s. co m Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(Exam.class) .setProjection(Projections.max("examId")).uniqueResult()) + 1; if (nextInt == null) { return 1; } nextNumber = nextInt.intValue(); } catch (Exception e) { } return nextNumber; }
From source file:com.aes.dao.impl.ExamScoresDaoImpl.java
@Override public int getNextId() { int nextNumber = 1; try {/* w ww.java 2 s.co m*/ Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(ExamScores.class) .setProjection(Projections.max("examScoresId")).uniqueResult()) + 1; if (nextInt == null) { return 1; } nextNumber = nextInt.intValue(); } catch (Exception e) { } return nextNumber; }
From source file:com.aes.dao.impl.PresentationDaoImpl.java
@Override public int getNextId() { int nextNumber = 1; try {// www . j ava 2 s . c om Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(Presentation.class) .setProjection(Projections.max("presentationId")).uniqueResult()) + 1; if (nextInt == null) { return 1; } nextNumber = nextInt.intValue(); } catch (Exception e) { } return nextNumber; }
From source file:com.aes.dao.impl.UserDetailsDaoImpl.java
@Override public int getNextId() { int nextNumber = 1; try {/*from w w w. j ava 2s .c o m*/ Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(UserDetails.class) .setProjection(Projections.max("userId")).uniqueResult()) + 1; if (nextInt == null) { return 1; } nextNumber = nextInt.intValue(); } catch (Exception e) { } return nextNumber; }
From source file:com.aes.dao.impl.UserTypeDaoImpl.java
@Override public int getNextId() { int nextNumber = 1; try {//from ww w .ja v a 2s . co m Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(UserType.class) .setProjection(Projections.max("userTypeId")).uniqueResult()) + 1; if (nextInt == null) { return 1; } nextNumber = nextInt.intValue(); } catch (Exception e) { } return nextNumber; }
From source file:com.amalto.core.storage.hibernate.StandardQueryHandler.java
License:Open Source License
@Override public StorageResults visit(Max max) { FieldCondition fieldCondition = max.getExpression().accept(criterionFieldCondition); for (String criterionFieldName : fieldCondition.criterionFieldNames) { projectionList.add(Projections.max(criterionFieldName)); }/* www. j av a 2s. c o m*/ return null; }
From source file:com.certus.actions.setOrderAction.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("cart"); User user = (User) request.getSession().getAttribute("user"); Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); Coupon coupon = (Coupon) request.getSession().getAttribute("coupon"); Criteria criteria = s.createCriteria(Order.class).setProjection(Projections.max("id")); Integer maxId = (Integer) criteria.uniqueResult(); if (cart != null && user != null) { String invo_id = "ord-" + new java.util.Date().getYear() + String.format("%03d", maxId == null ? 1 : maxId); cart.setInvoiceNum(invo_id);//ww w . j a v a 2 s . c o m String pids = ""; String sizes = ""; String qnties = ""; Order order = new Order(); s.beginTransaction(); order.setUser(user); order.setDateOrdered(new Date(new java.util.Date().getTime())); List<Double> dList = new ArrayList<>(); for (CartItem phs : cart.getShoppingList()) { pids += phs.getProduct_id() + ","; sizes += phs.getSize() + ","; qnties += phs.getQnty() + ","; dList.add(cart.getPriceofProduct(phs.getProduct_id(), phs.getSize()) * phs.getQnty()); } cart.setTotal(dList.stream().mapToDouble(x -> x).sum()); if (coupon != null) { order.setCoupon(coupon); cart.setCouponNum(coupon.getCouponCode()); Double totalWithCoupon = cart.getTotalWithCoupon(coupon.getDiscount()); cart.setTotal(totalWithCoupon); } order.setProductIds(removeLastChar(pids)); order.setSizes(removeLastChar(sizes)); order.setQuantities(removeLastChar(qnties)); order.setInvoNum(cart.getInvoiceNum()); order.setGrandTot(cart.getTotal()); s.save(order); s.getTransaction().commit(); s.close(); response.getWriter().write("Ok"); } else if (user == null) { response.getWriter().write("You have to login first !"); } }