Package nom

Examples of nom.Student


    return catalog;
  }

  public static void aplliedAction(List<CatalogBean> modificari) {
    Obiect ol = new Obiect();
    Student st=new Student();
    List<Catalog>removals=new ArrayList<Catalog>();
    int idStudent=-1;
    int idObiect=-1;
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("modul3L2");
    em = emf.createEntityManager();
    em.getTransaction().begin();
    idObiect=modificari.get(0).getC().getIdObiect();
    idStudent=modificari.get(0).getC().getIdStudent();
   
    Query query = em
        .createQuery("SELECT o FROM Obiect o WHERE o.idObiect=:v1 ")
        .setParameter("v1", idObiect);

    ol = (Obiect) query.getSingleResult();
    query = em
        .createQuery("SELECT s FROM Student s WHERE s.idStudent=:v1 ")
        .setParameter("v1", idStudent);
    st=(Student)query.getSingleResult();
   
   
    if (!ol.equals(null)) {
     ol.setCatalog(new ArrayList<Catalog>());
    }
    if(!st.equals(null)){
      st.setCatalog(new ArrayList<Catalog>());
    }
    for(CatalogBean cInd:modificari){
      if((cInd.getC().getIdObiect()==0)&&(cInd.getC().getIdStudent()==0)){
        cInd.getC().setIdObiect(idObiect);
        cInd.getC().setIdStudent(idStudent);
      }
      ol.getCatalog().add(cInd.getC());
      st.getCatalog().add(cInd.getC());
    }   
    em.merge(ol);
    em.merge(st);
     em.createNativeQuery(
         "DELETE FROM Catalog WHERE catalog_id_student is null AND catalog_id_obiect is null")
View Full Code Here


    if (q1 || q2) {

      return "student existent";
    } else {
      Student s = new Student();
      s.setAnStudiu(Integer.valueOf(studentForm.getAn()).intValue());
      s.setNrMatricol(studentForm.getNrMatricol());
      s.setNume(studentForm.getNume());
      s.setPrenume(studentForm.getPrenume());
      s.setEmail(studentForm.getEmail());
      List<Grupa> g = new ArrayList<Grupa>();
      EntityManagerFactory emf = Persistence
          .createEntityManagerFactory("modul3L2");
      em = emf.createEntityManager();
      em.getTransaction().begin();
      query = em.createQuery(
          "SELECT g FROM Grupa g WHERE g.numeGrupa=:v1")
          .setParameter("v1", studentForm.getGrupa());
      g = query.getResultList();
      Grupa gr = new Grupa();
      if (g.size() == 1) {

        gr = g.get(0);
        s.setIdGrupa(gr.getIdGrupa());
        gr.getStudenti().add(s);
        em.merge(gr);

      } else {
        gr.setNumeGrupa(studentForm.getGrupa());
        s.setIdGrupa(0);
        gr.getStudenti().add(s);
        em.persist(gr);
      }

    }
View Full Code Here

  public static void updateStudent(StudentForm studentUpdate,
      String nrMatricol) {

   
    Student toBeUpdatedStudent = new Student();
    Grupa g = new Grupa();
    EntityManagerFactory emf = Persistence
        .createEntityManagerFactory("modul3L2");
    em = emf.createEntityManager();
    em.getTransaction().begin();
    Query query = em.createQuery(
        "SELECT s FROM Student s WHERE s.nrMatricol=:v1").setParameter(
        "v1", nrMatricol);

    toBeUpdatedStudent = (Student) query.getSingleResult();
    String numeGrupa = (String) em
        .createNativeQuery(
            "SELECT grupa.NUME_GRUPA  FROM Grupa,Student WHERE grupa.ID_GRUPA=student.studenti_id_grupa AND student.NR_MATRICOL=?1")
        .setParameter(1, nrMatricol).getSingleResult();
    g = (Grupa) em
        .createQuery("SELECT g FROM Grupa g WHERE g.numeGrupa=:v1")
        .setParameter("v1", numeGrupa).getSingleResult();
    g.getStudenti().remove(g.getStudenti().indexOf(toBeUpdatedStudent));
    em.merge(g);
    toBeUpdatedStudent.setAnStudiu(Integer.valueOf(studentUpdate.getAn())
        .intValue());
    toBeUpdatedStudent.setNrMatricol(studentUpdate.getNrMatricol());
    toBeUpdatedStudent.setNume(studentUpdate.getNumeBaza());
    toBeUpdatedStudent.setPrenume(studentUpdate.getPrenume());
    toBeUpdatedStudent.setEmail(studentUpdate.getEmail());

    if (studentUpdate.getGrupa().equals(numeGrupa)) {
      g = (Grupa) em
          .createQuery("SELECT g FROM Grupa g WHERE g.numeGrupa=:v1")
          .setParameter("v1", numeGrupa).getSingleResult();
View Full Code Here

    if (st.size()==1) {

      return "student existent";
    }else{
      Student s=new Student();
      s.setAnStudiu(Integer.valueOf(studentForm.getAn()).intValue());
      s.setNrMatricol(studentForm.getNrMatricol());
      s.setNume(studentForm.getNume());
      s.setPrenume(studentForm.getPrenume());
      s.setEmail(studentForm.getEmail());
      List<Grupa> g=new ArrayList<Grupa>();
      em.getTransaction().begin();
      Query query = em
          .createQuery(
              "SELECT g FROM Grupa g WHERE g.numeGrupa=:v1")
          .setParameter("v1", studentForm.getGrupa());
      g=query.getResultList();
      Grupa gr= new Grupa();
      if (g.size()==1){
       
        gr=g.get(0);
        s.setIdGrupa(gr.getIdGrupa());
        gr.getStudenti().add(s);
        em.merge(gr);
       
      }else{
        gr.setNumeGrupa(studentForm.getGrupa());
        s.setIdGrupa(0);
        gr.getStudenti().add(s);
        em.persist(gr);
      }
     
     
View Full Code Here

TOP

Related Classes of nom.Student

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.