Package org.hibernate

Examples of org.hibernate.Session.createQuery()


        session.update(this);

        // get events inside the range
        final EventList el = eventLists.get(clazz.toString());
        java.util.List results =
          session.createQuery("from EventGeneric as ev where ev.eventList = :event_list " +
          "order by ev.date desc")
        .setString("event_list", el.getId().toString())
        .list();
        if (results.size() > 0) result = (EventGeneric) results.get(0);
View Full Code Here


        // j'ai eu �a ici et plus loin : Illegal attempt to associate a collection with two open sessions
      session.update(this);
      final EventList el = eventLists.get(clazz.toString());

      java.util.List results =
        session.createQuery("from EventGeneric as ev where ev.eventList = :event_list " +
        "and ev.date >= :start_date and ev.date <= :stop_date " +
        "order by ev.date asc")
      .setString("event_list", el.getId().toString())
      .setString("start_date", new java.sql.Timestamp(begin.getTime()).toString())
      .setString("stop_date", new java.sql.Timestamp(end.getTime()).toString())
View Full Code Here

      for (final EventGeneric event : (java.util.List<EventGeneric>) results)
        selected_events.add(event);

      // get event just before the beginning of the range
      results =
        session.createQuery("from EventGeneric as ev where ev.eventList = :event_list " +
        "and ev.date < :start_date " +
        "order by ev.date desc")
      .setString("event_list", el.getId().toString())
      .setString("start_date", new java.sql.Timestamp(begin.getTime()).toString())
      .list();
View Full Code Here

      if (results.size() >= 1)
        selected_events.add(0, (EventGeneric) results.get(0));

      // get event just after the last of the range
      results =
        session.createQuery("from EventGeneric as ev where ev.eventList = :event_list " +
        "and ev.date > :stop_date " +
        "order by ev.date asc")
      .setString("event_list", el.getId().toString())
      .setString("stop_date", new java.sql.Timestamp(end.getTime()).toString())
      .list();
View Full Code Here

      try  {
        for (final VisualElement elt : getGUI().getVisualTransient().getSubElements(Target.class)) {
          final Target target = (Target) elt;
          session.update(target);
          for (final String event_type : target.getEventLists().keySet()) {
            final Integer count = (Integer) session.createQuery("select count(*) from EventGeneric ev " +
                "where ev.eventList = :event_list")
                .setString("event_list", target.getEventLists().get(event_type).getId().toString()).uniqueResult();

            // merge old events
            if (count > new Integer(getConfig().getProperty("events.merge.threshold.0"))) {
View Full Code Here

    synchronized (synchro) {
      final Session session = synchro.getSessionFactory().getCurrentSession();
      session.beginTransaction();

      final java.util.List results =
        session.createQuery("from TargetGroup as group where group.item = ?").
        setString(0, args[2]).list();

      if (results.size() == 0) log.error("no such group");
      else {
        final TargetGroup group = (TargetGroup) results.get(0);
View Full Code Here

              .setLong("event_list",
                  group.getEventLists().get(EventGenericSrc.class.toString()).getId())
              .setDate("date", date)
              .list();*/
            final java.util.List results2 =
              session.createQuery("from EventGenericSrc as ev where ev.date = :date")
//              .setString("date", "2008-05-30 16:24:20.000000000")
              .setString("date", new java.sql.Date(date.getTime()).toString())
              .list();
log.debug("date en ascii:" + new java.sql.Date(date.getTime()).toString());

View Full Code Here

    public CustomerListTableModel(String hql) {
        super();
        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();
        Vector<Object[]> customers = new Vector<Object[]>();
        for (Object cus : sess.createQuery("from Customer" + hql).list()) {
            Customer c = (Customer) cus;
            customers.add(new Object[] {
                c.getId(),
                c.getUser().getUsername(),
                c.getUser().getFirstName(),
View Full Code Here

    public EmployeeListTableModel(String hql) {
        super();
        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();
        Vector<Object[]> employees = new Vector<Object[]>();
        for (Object emp : sess.createQuery("from Employee" + hql).list()) {
            Employee e = (Employee) emp;
            employees.add(new Object[] {
                e.getId(),
                e.getUser().getUsername(),
                e.getUser().getFirstName(),
View Full Code Here

     * @return True if the login was successful, false otherwise
     */
    public boolean doLogin(String username, String password) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        user = (User) session.createQuery("from User where username = ?").setString(0, username).uniqueResult();
        try {
            if (user.authenticate(password)) {
                //session.getTransaction().commit();
                return true;
            }
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.