Package org.springframework.orm.hibernate3

Examples of org.springframework.orm.hibernate3.HibernateTemplate


  @Transactional(readOnly = false)
  public boolean moveScheduleUp(Schedule schedule)
  {
    synchronized (Schedule.class)
    {
      HibernateTemplate htl = getHibernateTemplate();

      if (schedule.getPosition() > 1)
      {
        List<Schedule> prevSchedules = htl.find("from Schedule where position = ?", schedule.getPosition() - 1);

        if (prevSchedules.size() > 0)
        {
          prevSchedules.get(0).setPosition(schedule.getPosition());
          htl.update(prevSchedules.get(0));
        }

        schedule.setPosition(schedule.getPosition() - 1);
        htl.update(schedule);

        return true;
      }

      return false;
View Full Code Here


  @Transactional(readOnly = false)
  public boolean moveScheduleDown(Schedule schedule)
  {
    synchronized (Schedule.class)
    {
      HibernateTemplate htl = getHibernateTemplate();
      Integer maxPosition = (Integer) htl.find("select max(position) from Schedule").get(0);

      if (schedule.getPosition() < maxPosition)
      {
        List<Schedule> nextSchedules = htl.find("from Schedule where position = ?", schedule.getPosition() + 1);

        if (nextSchedules.size() > 0)
        {
          nextSchedules.get(0).setPosition(schedule.getPosition());
          htl.update(nextSchedules.get(0));
        }

        schedule.setPosition(schedule.getPosition() + 1);
        htl.update(schedule);

        return true;
      }

      return false;
View Full Code Here

  @Transactional(readOnly = false)
  public boolean moveScheduleToFront(Schedule schedule)
  {
    synchronized (Schedule.class)
    {
      HibernateTemplate htl = getHibernateTemplate();
      List<Schedule> prevSchedules = htl.find("from Schedule where position < ?", schedule.getPosition());

      for (Schedule prevSchedule : prevSchedules)
      {
        prevSchedule.setPosition(prevSchedule.getPosition() + 1);
        htl.update(prevSchedule);
      }

      if (schedule.getPosition() != 1)
      {
        schedule.setPosition(1);
        htl.update(schedule);

        return true;
      }

      return false;
View Full Code Here

  @Transactional(readOnly = false)
  public boolean moveScheduleToEnd(Schedule schedule)
  {
    synchronized (Schedule.class)
    {
      HibernateTemplate htl = getHibernateTemplate();
      Integer maxPosition = (Integer) htl.find("select max(position) from Schedule").get(0);
      List<Schedule> nextSchedules = htl.find("from Schedule where position > ?", schedule.getPosition());

      for (Schedule nextSchedule : nextSchedules)
      {
        nextSchedule.setPosition(nextSchedule.getPosition() - 1);
        htl.update(nextSchedule);
      }

      if (schedule.getPosition() != maxPosition)
      {
        schedule.setPosition(maxPosition);
        htl.update(schedule);

        return true;
      }

      return false;
View Full Code Here

  /**
   * @see de.iritgo.aktera.configuration.preferences.PreferencesDAO#findPreferencesByUserId(java.lang.Integer)
   */
  public Preferences findPreferencesByUserId(Integer userId)
  {
    HibernateTemplate htl = getHibernateTemplate();
    List<Preferences> res = htl.find("from Preferences where userId = ?", userId);

    return res.size() > 0 ? res.get(0) : null;
  }
View Full Code Here

  /**
   * @see de.iritgo.aktera.configuration.preferences.PreferencesDAO#findPreferencesConfig(java.lang.Integer, java.lang.String, java.lang.String)
   */
  public PreferencesConfig findPreferencesConfig(Integer userId, String category, String name)
  {
    HibernateTemplate htl = getHibernateTemplate();
    List<PreferencesConfig> res = htl.find("from PreferencesConfig where userId = ? and category = ? and name = ?",
            new Object[]
            {
                    userId, category, name
            });

View Full Code Here

    /**
     * Sets Hibernate session factory.
     */
    public void setSessionFactory(SessionFactory sessionFactory) {
        template = new HibernateTemplate(sessionFactory);
    }
View Full Code Here

    /**
     * Sets Hibernate session factory.
     */
    public void setSessionFactory(SessionFactory sessionFactory) {
        template = new HibernateTemplate(sessionFactory);
    }
View Full Code Here

     * <p>setSessionFactory</p>
     *
     * @param sessionFactory a {@link org.hibernate.SessionFactory} object.
     */
    public void setSessionFactory(SessionFactory sessionFactory) {
        m_template = new HibernateTemplate(sessionFactory);
    }
View Full Code Here

public class UserDAOHibernate implements UserDAO {

  private HibernateTemplate hibernateTemplate;

  public void setSessionFactory(SessionFactory sessionFactory) {
    this.hibernateTemplate = new HibernateTemplate(sessionFactory);
  }
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.