Example usage for org.hibernate.criterion Projections max

List of usage examples for org.hibernate.criterion Projections max

Introduction

In this page you can find the example usage for org.hibernate.criterion Projections max.

Prototype

public static AggregateProjection max(String propertyName) 

Source Link

Document

A property maximum value projection

Usage

From source file:co.com.codesoftware.logic.ProductoLogic.java

/**
 * Funcion que consulta el count de la tabla de productos
 *
 * @return/*from   w w w. j av  a 2  s  .  c om*/
 */
public Integer consultaCount() {
    Criteria crit = sesion.createCriteria(ProductoEntity.class);
    crit.setProjection(Projections.max("id"));
    Integer count = (Integer) crit.uniqueResult() + 1;
    return count;
}

From source file:co.com.codesoftware.logic.productos.PedidosLogic.java

/**
 * metodo que consulta el id de la tabla
 *
 * @return/*  ww  w.j a  va 2s .c o  m*/
 */
public Integer selectMaxPedido() {
    Integer resultado = 1;
    try {
        Criteria crit = sesion.createCriteria(PedidoEntity.class).setProjection(Projections.max("id"));
        resultado = (Integer) crit.uniqueResult() + 1;
    } catch (Exception e) {
        resultado = 1;
        e.printStackTrace();
    }
    return resultado;
}

From source file:co.com.codesoftware.logic.productos.PedidosProductoLogic.java

/**
 * metodo que consulta el id de la tabla
 *
 * @return//  w  w w .ja  v a2s  . com
 */
public Integer selectMaxPedidoProdcuto() {
    Integer resultado = 1;
    try {
        Criteria crit = sesion.createCriteria(PedidoProductoEntity.class).setProjection(Projections.max("id"));
        resultado = (Integer) crit.uniqueResult() + 1;
    } catch (Exception e) {
        resultado = 1;
        e.printStackTrace();
    }
    return resultado;
}

From source file:co.com.codesoftware.logic.ProductoTmpLogic.java

/**
 * Funcion para consultar el maximo de una tabla
 *
 * @return/*from  ww  w .  j  a  v  a2  s  .  c om*/
 */
public Integer consultaMax() {
    Criteria crit = sesion.createCriteria(ProductoTmpEntity.class);
    crit.setProjection(Projections.max("id"));
    Integer count = 1;
    try {
        count = (Integer) crit.uniqueResult() + 1;
    } catch (Exception e) {
        count = 1;
    }
    return count;
}

From source file:co.com.codesoftware.logic.ProveedoresLogic.java

/**
 * Metodo que consulta el valor mximo del campo id
 *
 * @return/*from ww w.  jav a  2 s  . c o m*/
 */
public Integer selectMaxProveedor() {
    Integer resultado = null;
    try {
        Criteria crit = sesion.createCriteria(ProveedoresEntity.class).setProjection(Projections.max("id"));
        resultado = (Integer) crit.uniqueResult() + 1;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return resultado;
}

From source file:co.com.codesoftware.logic.ReferenciaLogic.java

/**
 * Funcion que consulta el maximo del id de la marca y le suma 1
 *
 * @return//w ww.ja  va 2 s  . co  m
 */
public Integer selectMaxReferencia() {
    Integer resultado = null;
    try {
        Criteria crit = sesion.createCriteria(ReferenciaEntity.class).setProjection(Projections.max("id"));
        resultado = (Integer) crit.uniqueResult() + 1;
    } catch (Exception e) {
        resultado = 1;
        e.printStackTrace();
    }
    return resultado;
}

From source file:co.com.codesoftware.logica.inventario.ConteoLogica.java

/**
 * Funcion con la cual obtengo el numero maximo del producto conteo para la
 * insercion de la misma/*from  w w  w. j  a  v  a  2s  .  co  m*/
 *
 * @return
 */
public Integer selectMaxProductoConteo() {
    Integer resultado = 1;
    try {
        Criteria crit = sesion.createCriteria(ProductoConteoEntity.class).setProjection(Projections.max("id"));
        resultado = (Integer) crit.uniqueResult() + 1;
    } catch (Exception e) {
        resultado = 1;
        e.printStackTrace();
    }
    return resultado;
}

From source file:co.com.codesoftware.logica.inventario.ConteoLogica.java

/**
 * Funcion con la cual obtengo el max de un conteo
 * @return // w  w w  . j a va  2  s. c  o  m
 */
public Integer selectMaxConteo() {
    Integer resultado = 1;
    try {
        Criteria crit = sesion.createCriteria(ConteoEntity.class).setProjection(Projections.max("id"));
        resultado = (Integer) crit.uniqueResult() + 1;
    } catch (Exception e) {
        resultado = 1;
        e.printStackTrace();
    }
    return resultado;
}

From source file:com.aes.dao.impl.BusinessUnitDaoImpl.java

@Override
public int getNextId() {
    int nextNumber = 1;
    try {/*from   w  w  w. j a  v  a  2 s.c o m*/
        Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(BusinessUnit.class)
                .setProjection(Projections.max("businessUnitId")).uniqueResult()) + 1;
        if (nextInt == null) {
            return 1;
        }
        nextNumber = nextInt.intValue();

    } catch (Exception e) {

    }
    return nextNumber;
}

From source file:com.aes.dao.impl.ChapterDaoImpl.java

@Override
public int getNextId() {
    int nextNumber = 1;
    try {/*w  w w .j av a  2  s  .co  m*/
        Integer nextInt = ((Integer) session.getCurrentSession().createCriteria(Chapter.class)
                .setProjection(Projections.max("chapterId")).uniqueResult()) + 1;
        if (nextInt == null) {
            return 1;
        }
        nextNumber = nextInt.intValue();

    } catch (Exception e) {

    }
    return nextNumber;
}