public static List findOne(String login, String senha) { Query query = JpaUtil.getEntityManager() .createQuery("select a from Usuario a where a.login = :vlogin and a.senha = :vsenha"); query.setParameter("vlogin", login); query.setParameter("vsenha", senha); return query.getResultList(); }
public void create(Lieu lieu) throws Throwable { EntityManager em = JpaUtil.obtenirEntityManager(); try { em.persist(lieu); } catch (Exception e) { throw e; } }
public Lieu update(Lieu lieu) throws Throwable { EntityManager em = JpaUtil.obtenirEntityManager(); try { lieu = em.merge(lieu); } catch (Exception e) { throw e; } return lieu; }
public static Adherent update(Adherent adherent) throws Throwable { EntityManager em = JpaUtil.obtenirEntityManager(); try { adherent = em.merge(adherent); } catch (Exception e) { throw e; } return adherent; }
public Lieu findById(long id) throws Throwable { EntityManager em = JpaUtil.obtenirEntityManager(); Lieu lieu = null; try { lieu = em.find(Lieu.class, id); } catch (Exception e) { throw e; } return lieu; }
public static Adherent findById(long id) throws Throwable { EntityManager em = JpaUtil.obtenirEntityManager(); Adherent adherent = null; try { adherent = em.find(Adherent.class, id); } catch (Exception e) { throw e; } return adherent; }
public static List<Adherent> findAll() throws Throwable { EntityManager em = JpaUtil.obtenirEntityManager(); List<Adherent> adherents = null; try { Query q = em.createQuery("SELECT a FROM Adherent a"); adherents = (List<Adherent>) q.getResultList(); } catch (Exception e) { throw e; } return adherents; }
public List<Lieu> findAll() throws Throwable { EntityManager em = JpaUtil.obtenirEntityManager(); List<Lieu> lieux = null; try { Query q = em.createQuery("SELECT l FROM Lieu l"); lieux = (List<Lieu>) q.getResultList(); } catch (Exception e) { throw e; } return lieux; }
public static boolean create(Adherent adherent) throws Throwable { if (adherent.getLatitude() != null) { EntityManager em = JpaUtil.obtenirEntityManager(); try { em.persist(adherent); return true; } catch (Exception e) { throw e; } } return false; }
public static Adherent findByMail(String mail) throws Throwable { EntityManager em = JpaUtil.obtenirEntityManager(); Adherent adherent = null; try { Query q = em.createQuery("SELECT a FROM Adherent a WHERE a.mail=:mail"); q.setParameter("mail", mail); adherent = (Adherent) q.getSingleResult(); } catch (Exception e) { throw e; } return adherent; }
public static void main(String[] args) { // TODO code application logic here JpaUtil.creerEntityManager(); ServiceInit.initialisationPays(); ServiceInit.initialisationConseiller(); ServiceInit.initialisationCircuit(); ServiceInit.initialisationSejour(); ServiceInit.initialisationInfoPrincipale(); ServiceInit.initialisationClient(5); saisieInteractive(); }