コード例 #1
0
ファイル: DataManager.java プロジェクト: mhylle/schema
  public EventNumberOfPassesRequest getEventPassesRequest(User user, Event event) {
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    try {
      Transaction transaction = session.beginTransaction();
      List result =
          session
              .createQuery(
                  "from EventNumberOfPassesRequest as eventNumberOfPassesRequest "
                      + "where eventNumberOfPassesRequest.idevent="
                      + event.getIdevent()
                      + " and eventNumberOfPassesRequest.iduser="
                      + user.getIduser())
              .list();
      transaction.commit();

      if (result != null && result.size() > 0) {
        return (EventNumberOfPassesRequest) result.get(0);
      }
    } finally {
      if (session.isOpen()) {
        session.disconnect();
        session.close();
      }
    }
    return null;
  }
コード例 #2
0
ファイル: DataManager.java プロジェクト: mhylle/schema
 public List<Activity> getActivities(Event parent) {
   List<Activity> result = new ArrayList<Activity>();
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   try {
     Transaction transaction = session.beginTransaction();
     Object event =
         session
             .createQuery("from Event as event where event.idevent= " + parent.getIdevent())
             .uniqueResult();
     transaction.commit();
     if (event != null) {
       Event eventEntity = (Event) event;
       Collection<Activity> activityList = eventEntity.getActivities();
       for (Activity activity : activityList) {
         result.add(activity);
       }
     }
   } finally {
     if (session.isOpen()) {
       session.flush();
       session.disconnect();
       session.close();
     }
   }
   return result;
 }
コード例 #3
0
ファイル: DataManager.java プロジェクト: mhylle/schema
 public Event getEvent(Event event) {
   Event result = null;
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   try {
     Transaction transaction = session.beginTransaction();
     Object o =
         session
             .createQuery("from Event as event where event.idevent= " + event.getIdevent())
             .uniqueResult();
     transaction.commit();
     if (o != null) {
       result = (Event) o;
     }
   } finally {
     if (session.isOpen()) {
       session.disconnect();
       session.close();
     }
   }
   return result;
 }
コード例 #4
0
ファイル: DataManager.java プロジェクト: mhylle/schema
  public List<User> getUserForEvent(Event selectedEvent) {
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    List<User> result = new ArrayList<User>();
    try {
      Transaction transaction = session.beginTransaction();

      String queryString =
          "select user from User as user where "
              + selectedEvent.getIdevent()
              + " in elements (user.events) order by user.firstname";
      List users = session.createQuery(queryString).list();
      transaction.commit();

      for (Object user : users) {
        result.add((User) user);
      }
    } finally {
      if (session.isOpen()) {
        session.disconnect();
        session.close();
      }
    }
    return result;
  }