Package org.springframework.orm.hibernate3

Examples of org.springframework.orm.hibernate3.HibernateTemplate


    public HibernateCountryDao(DaoHelper helper) {
        super(helper, Country.class);
    }

    public List findAdvancedCountries() {
        HibernateTemplate t = new HibernateTemplate(getSessionFactory());
       
        return (List)t.execute(
                new HibernateCallback() {
                    public Object doInHibernate(Session s) throws HibernateException, SQLException {
                        // TODO filtrer
                        return s.createCriteria(Country.class).list();
                    }
View Full Code Here


                }
        );
    }

    public List findEECCountries() {
        HibernateTemplate t = new HibernateTemplate(getSessionFactory());
       
        return (List)t.execute(
                new HibernateCallback() {
                    public Object doInHibernate(Session s) throws HibernateException, SQLException {
                        // TODO filtrer
                        return s.createCriteria(Country.class)
                          .add(Expression.eq("inEEC", new Integer(1)))
View Full Code Here

                }
        );
    }

  public Country findCountryFromName(final String country) {
        HibernateTemplate t = new HibernateTemplate(getSessionFactory());
       
        return (Country)t.execute(
                new HibernateCallback() {
                    public Object doInHibernate(Session s) throws HibernateException, SQLException {
                        return s.createCriteria(Country.class)
                          .add(Expression.eq("name", country))
                          .uniqueResult();
View Full Code Here

    public HibernateOrderDao(DaoHelper helper) {
        super(helper, Order.class);
    }

  public Order getOrderWithNoPayment(UserImpl user, String product, Integer users, Integer years) {
    List list = new HibernateTemplate(getSessionFactory()).find("from "+ Order.class.getName()+" o  where o.payment is null and  o.buyer= ? and o.subscribedUsers=? and o.subscribedYears=? and price.product.code=?", new Object[]{user, users, years, product});
    if(list != null && list.size()>0) {
      return (Order) list.get(0);
    }
    return null;
  }
View Full Code Here

    }
    return null;
  }
 
    public List getOrdersOfUser(User user) {
        return new HibernateTemplate(getSessionFactory()).find("from "+ Order.class.getName()+" o  where o.buyer = ? ", new Object[]{user});
    }
View Full Code Here

    }

    public void fetch(WOJObject o) throws DaoException {
        if (o instanceof Order) {
            final Order order = (Order)o;
            HibernateTemplate t = new HibernateTemplate(getSessionFactory());
            t.execute(
                    new HibernateCallback() {
                        public Object doInHibernate(Session s) throws HibernateException, SQLException {
                            s.lock(order, LockMode.NONE);
                            if(order.getSuccessPayment() != null) {
                              order.getSuccessPayment().getTransactionId();
View Full Code Here

    public HibernateSpecialOfferDao(DaoHelper helper) {
        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

    }
    return null;
  }
 
  public List getProductSpecialOffer(String productCode) {
    HibernateTemplate t = new HibernateTemplate(getSessionFactory());
    return t.find("from "+ SpecialOffer.class.getName()+" so fetch all properties where so.relatedPrice.product.code = ? and so.validUntil>=? and so.enabled=1 and so.maxSubscription > so.counter.value", new Object[]{productCode, new Long(System.currentTimeMillis())});
  }
View Full Code Here

    public void fetch(WOJObject o) throws DaoException {
    }

    public List getAllSpecialOffer() {
        HibernateTemplate t = new HibernateTemplate(getSessionFactory());
        return t.find("from "+ SpecialOffer.class.getName()+" so fetch all properties where so.validUntil>=? and so.enabled=1 and so.maxSubscription > so.counter.value", new Object[]{new Long(System.currentTimeMillis())});
    }
View Full Code Here

    public HibernateGroupDao(DaoHelper helper) {
        super(helper, Group.class);
    }

    public Group[] findUpdatedGroups(final Long since) {
        HibernateTemplate t = new HibernateTemplate(getSessionFactory());

        return (Group[])t.execute(
                new HibernateCallback() {
                    public Object doInHibernate(Session s) throws HibernateException, SQLException {
                      LOGGER.debug("finding groups updated since " + since);
                     
                      List foundGroups = s.createCriteria(Group.class)
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.