Package org.springframework.orm.hibernate3

Examples of org.springframework.orm.hibernate3.HibernateTemplate.find()


   
    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) {
View Full Code Here


        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

     */
    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

    }

    public ClufVersionImpl getCurrentClufVersion() {
        HibernateTemplate t = new HibernateTemplate(getSessionFactory());
        Number maxId = new Long(0);
        List maxIds = t.find("select max(m.id) from " + ClufVersionImpl.class.getName() + " m");
        if(maxIds != null && maxIds.size() >0) {
            maxId = (Number) maxIds.get(0);
        }
        List foundClufs = t.find("from " + ClufVersionImpl.class.getName() + " c where c.id = ?", maxId);
        if (foundClufs.size() == 0) {
View Full Code Here

        Number maxId = new Long(0);
        List maxIds = t.find("select max(m.id) from " + ClufVersionImpl.class.getName() + " m");
        if(maxIds != null && maxIds.size() >0) {
            maxId = (Number) maxIds.get(0);
        }
        List foundClufs = t.find("from " + ClufVersionImpl.class.getName() + " c where c.id = ?", maxId);
        if (foundClufs.size() == 0) {
            LOGGER.warn("no current cluf found");
            throw new IllegalStateException("no current cluf found");
        }
        LOGGER.debug("found " + foundClufs.size() + " cluf as current cluf");
View Full Code Here

    }

    public synchronized ClufImpl getCurrentVersion(String language) {
        HibernateTemplate t = new HibernateTemplate(getSessionFactory());
        ClufVersionImpl version = getCurrentClufVersion();
        List currentCluf = t.find("from " + ClufImpl.class.getName() + " c where c.clufVersion = ? and c.language = ?", new Object[] {version, language});
        if (currentCluf.size() == 0) {
            if ("en".equals(language)) {
                throw new IllegalStateException("no cluf found for "+version.getVersion()+" language=en");
            } else {
                // maybe the language is unknown, let's try with english
View Full Code Here

        if (currentCluf.size() == 0) {
            if ("en".equals(language)) {
                throw new IllegalStateException("no cluf found for "+version.getVersion()+" language=en");
            } else {
                // maybe the language is unknown, let's try with english
                currentCluf = t.find("from " + ClufImpl.class.getName() + " c where c.clufVersion = ? and c.language = ?", new Object[] {version, "en"});
                if (currentCluf.size() == 0) {
                    throw new IllegalStateException("no cluf found for "+version.getVersion()+" language="+language+",en");
                }
            }
        }
View Full Code Here

        super(helper, Product.class);
    }

    public Product getProduct(String code) {
    HibernateTemplate t = new HibernateTemplate(getSessionFactory());
    List result = t.find("from "+ Product.class.getName()+"  product where product.code = ?", new Object[]{code});
    if(result != null && result.size()>0) {
      return (Product) result.get(0);
    }
    return null;
  }
View Full Code Here

        super(helper, PaymentInfo.class);
    }

    public PaymentInfo getPayment(Order pendingOrder) {
    HibernateTemplate t = new HibernateTemplate(getSessionFactory());
    List result = t.find("from "+ PaymentInfo.class.getName()+" pay  where pay.order = ? ", new Object[]{pendingOrder});
    if(result != null && result.size()>0) {
      return (PaymentInfo) result.get(0);
    }
    return null;
  }
View Full Code Here

        super(helper, SpecialOffer.class);
    }

    public SpecialOffer getSpecialOffer(Price price) {
    HibernateTemplate t = new HibernateTemplate(getSessionFactory());
    List result = t.find("from "+ SpecialOffer.class.getName()+" so  where so.relatedPrice = ? and so.validUntil>=? and so.enabled=1 and so.maxSubscription > so.counter.value", new Object[]{price, new Long(System.currentTimeMillis())});
    if(result != null && result.size()>0) {
      return (SpecialOffer) result.get(0);
    }
    return null;
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.