コード例 #1
0
ファイル: Node.java プロジェクト: Eugenitals/vabkhazii-back
  public static List<Node> findRootNodes(long regionId) {
    EntityManager em = Node.entityManager();
    TypedQuery<Node> q =
        em.createQuery(
            "SELECT o FROM Node AS o WHERE o.parent IS NULL AND dtype = 'Node'", Node.class);
    Node root = q.getSingleResult();

    return findNodesByParent(root, regionId);
  }
コード例 #2
0
 public User findUser(long id) {
   TypedQuery<User> query =
       entityManager.createQuery("SELECT u FROM User u WHERE u.id = " + id + "", User.class);
   try {
     User u = query.getSingleResult();
     u.setPermissions("root"); // TODO: dit moet natuurlijk anders! (moet uit de DB komen)
     return u;
   } catch (NoResultException e) {
   }
   return null;
 }
コード例 #3
0
  @Override
  public Withdrawal get(Trading trading, Currency currency) {
    TypedQuery<Withdrawal> query =
        (TypedQuery<Withdrawal>)
            em.createQuery(
                "SELECT w FROM Withdrawal w WHERE w.pk.trading=:trading AND w.pk.currency=:currency");
    query.setParameter("trading", trading);
    query.setParameter("currency", currency);

    try {
      return query.getSingleResult();
    } catch (NoResultException e) {
      return null;
    }
  }
コード例 #4
0
 public User findUser(String username, String passwd) {
   try {
     TypedQuery<User> query =
         entityManager.createQuery(
             "SELECT u FROM User u WHERE u.username = :username and u.passwd=:passwd", User.class);
     query.setParameter("username", username);
     query.setParameter("passwd", passwd);
     User u = query.getSingleResult();
     u.setPermissions("root"); // TODO: dit moet natuurlijk anders! (moet uit de DB komen)
     return u;
   } catch (NoResultException e) {
     e.printStackTrace();
   }
   return null;
 }