Package org.springframework.orm.hibernate3

Examples of org.springframework.orm.hibernate3.HibernateTemplate


    }
    return execute;
  }

  public long staccaNumeroAntiMafia() throws ImpossibileGenerareNumeroAntiMafiaException {
    HibernateTemplate hibernateTemplate = getHibernateTemplate();
    Long execute = 0l;
    try {
      execute = (Long) hibernateTemplate.execute(new HibernateCallback() {
        public Object doInHibernate(Session session) {
          BigDecimal nextVal = (BigDecimal) session.createSQLQuery("select sq_antm.nextval from DUAL")
              .uniqueResult();
          return nextVal.longValue();
        }
View Full Code Here


  }
 
  @Override
  // il metodo nel ContabilitaDaoHibernateImpl andrebbe tolto e andrebbe lasciato solo questo
  public long staccaNumeroArticolo() throws ImpossibileGenerareNumeroArticoloException {
    HibernateTemplate hibernateTemplate = getHibernateTemplate();
    return (Long) hibernateTemplate.execute(new HibernateCallback() {
      public Object doInHibernate(Session session) {
        BigDecimal nextVal = (BigDecimal) session.createSQLQuery("select SQ_ARTICOLI.NEXTVAL from DUAL")
            .uniqueResult();
        return nextVal.longValue();
      }
View Full Code Here

  }
 
  @Override
  // il metodo nel ContabilitaDaoHibernateImpl andrebbe tolto e andrebbe lasciato solo questo
  public long staccaNumeroArticoloCustom() throws ImpossibileGenerareNumeroArticoloCustomException {
    HibernateTemplate hibernateTemplate = getHibernateTemplate();
    return (Long) hibernateTemplate.execute(new HibernateCallback() {
      public Object doInHibernate(Session session) {
        BigDecimal nextVal = (BigDecimal) session.createSQLQuery(
            "select SQ_MOVCONT_" + legalEntity + "_" + organizationUnit + ".NEXTVAL from DUAL")
            .uniqueResult();
        return nextVal.longValue();
View Full Code Here

        try {
            sessionFactoryBean.afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException("Could not set up database connection", e);
        }
        hibernateTemplate = new HibernateTemplate((SessionFactory) sessionFactoryBean.getObject());
    }
View Full Code Here

        Collection<Space> spaces = user.getSpaces();
        if (spaces.size() == 0) {
            return null;
        }
        CountsHolder ch = new CountsHolder();
        HibernateTemplate ht = getHibernateTemplate();
        List<Object[]> loggedByList = ht.find("select item.space.id, count(item) from Item item"
                + " where item.loggedBy.id = ? group by item.space.id", user.getId());
        List<Object[]> assignedToList = ht.find("select item.space.id, count(item) from Item item"
                + " where item.assignedTo.id = ? group by item.space.id", user.getId());
        List<Object[]> statusList = ht.findByNamedParam("select item.space.id, count(item) from Item item"
                + " where item.space in (:spaces) group by item.space.id", "spaces", spaces);
        for(Object[] oa : loggedByList) {
            ch.addLoggedByMe((Long) oa[0], (Long) oa[1]);
        }
        for(Object[] oa : assignedToList) {
View Full Code Here

        }
        return ch;
    }
   
    public Counts loadCountsForUserSpace(User user, Space space) {
        HibernateTemplate ht = getHibernateTemplate();
        List<Object[]> loggedByList = ht.find("select status, count(item) from Item item"
                + " where item.loggedBy.id = ? and item.space.id = ? group by item.status", new Object[] {user.getId(), space.getId()});
        List<Object[]> assignedToList = ht.find("select status, count(item) from Item item"
                + " where item.assignedTo.id = ? and item.space.id = ? group by item.status", new Object[] {user.getId(), space.getId()});
        List<Object[]> statusList = ht.find("select status, count(item) from Item item"
                + " where item.space.id = ? group by item.status", space.getId());
        Counts c = new Counts(true);
        for(Object[] oa : loggedByList) {
            c.addLoggedByMe((Integer) oa[0], (Long) oa[1]);
        }
View Full Code Here

   * Create a HibernateTemplate from the SessionFactory and call flush() and
   * clear() on it. Designed to be used after "save" methods in tests:
   * http://issues.appfuse.org/browse/APF-178.
   */
  protected final void flush() {
    final HibernateTemplate hibernateTemplate = new HibernateTemplate(
        (SessionFactory) this.applicationContext
            .getBean("sessionFactory"));
    hibernateTemplate.flush();
    hibernateTemplate.clear();
  }
View Full Code Here

     */
    @SuppressWarnings(Constants.SUPPRESS_WARNINGS_UNCHECKED)
    public final List<T> getPage(final int pag, final int numRes) {
        List<T> result = null;
        try {
            final HibernateTemplate ht = super.getHibernateTemplate();
            final CrudHibernateTemplate lht = new CrudHibernateTemplate(ht);
            result = lht.loadPage(this.persistentClass, pag, numRes);
        } catch (final Exception e) {
            this.log.error("ERROR al obtener la página " + pag + " en BD:\n "
                    + e);
View Full Code Here

    @SuppressWarnings(Constants.SUPPRESS_WARNINGS_UNCHECKED)
    public final List<T> getPage(final int pag, final int numRes,
            final String orderColumn, final boolean ascendingOrder) {
        List<T> result = null;
        try {
            final HibernateTemplate ht = super.getHibernateTemplate();

            final CrudHibernateTemplate lht = new CrudHibernateTemplate(ht);
            result = lht.loadPage(this.persistentClass, pag, numRes,
                    orderColumn, ascendingOrder);
        } catch (final Exception e) {
View Full Code Here

     * {@inheritDoc}
     */
    public final Long countAll() {
        Long result = 0L;
        try {
            final HibernateTemplate ht = super.getHibernateTemplate();
            final List<?> datos = ht.find("select count(*) from "
                    + this.persistentClass.getName());
            if (datos.size() == 1) {
                result = (Long) datos.get(0);
            }
        } catch (final Exception e) {
View Full Code Here

TOP

Related Classes of org.springframework.orm.hibernate3.HibernateTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.