Package org.jpa

Examples of org.jpa.Student


   
    g.setNumeGrupa("gr1");
    em.persist(g);
    int idgr = g.getIdGrupa();
    for (int i = 0; i < 3; i++) {
      s = new Student();
      s.setIdGrupa(0);
      s.setAnStudiu(1);
      s.setEmail("email");
      s.setNrMatricol(1);
      s.setNume("Student_" + i);
View Full Code Here


    int anStudiuTest = 2;
    String emailTest = "email";
    String numarMatricolTest = "1";
    String numeTest = "numeStudentTest";
    String prenumeTest = "prenumeStudentTest";
    Student s = new Student();
    s.setIdGrupa(1);
    s.setAnStudiu(anStudiuTest);
    s.setEmail(emailTest);
    s.setNrMatricol(numarMatricolTest);
    s.setNume(numeTest);
    s.setPrenume(prenumeTest);
    return s;

  }
View Full Code Here

  @Test
  public void testPersistDeleteUpdateStudent() {
    String numeTestUpdate = "numeStudentUpdate";
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    Student studentTest = new Student();
    studentTest = initTest1();
    em.persist(studentTest);
    em.getTransaction().commit();
    Query q = em.createQuery("select st from Student st where st.nume='numeStudentTest' ");
    Student st = new Student();
    st = (Student) q.getSingleResult();
    assertTrue("numeStudentTest".equals(st.getNume()));
    em.getTransaction().begin();
    st.setNume(numeTestUpdate);
    em.getTransaction().commit();
    q = em.createQuery("select st from Student st");
    Student st1 = new Student();
    st1 = (Student) q.getSingleResult();
    assertEquals(st1.getNume(), numeTestUpdate);
    em.getTransaction().begin();
    q = em.createQuery("Delete from Student s");
    int deletedData = q.executeUpdate();
    em.getTransaction().commit();
    assertEquals(deletedData, 1);
View Full Code Here

    em.persist(g);
    int idGr = g.getIdGrupa();
    final int n = 3;

    for (int i = 0; i < n; i++) {
      Student s = new Student();
      s.setIdGrupa(idGr);
      s.setAnStudiu(anStudiuTest);
      s.setEmail(emailTest);
      s.setNrMatricol(String.valueOf(i));
      s.setNume(numeTest + String.valueOf(i));
      s.setPrenume(prenumeTest + String.valueOf(i));
      g.getStudenti().add(s);
      em.persist(g);
    }
    em.getTransaction().commit();
    em.getTransaction().begin();
View Full Code Here

    int nrPrezenteTest = 20;
    int idObiectTest = 5;
    final int n = 3;
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    Student studentTest = new Student();
    studentTest.setIdGrupa(1);
    studentTest.setAnStudiu(anStudiuTest);
    studentTest.setEmail(emailTest);
    studentTest.setNrMatricol(numarMatricolTest);
    studentTest.setNume(numeTest);
    studentTest.setPrenume(prenumeTest);

    em.persist(studentTest);
    for (int i = 0; i < n; i++) {
      Catalog catalogTest = new Catalog();
      catalogTest.setIdStudent(studentTest.getIdStudent());
      catalogTest.setDataNotei(new Date());

      catalogTest.setIdObiect(idObiectTest + i);
      catalogTest.setNota(notaTest);
      catalogTest.setNrPrezente(nrPrezenteTest);
      studentTest.getCatalog().add(catalogTest);
    }

    em.persist(studentTest);
    em.getTransaction().commit();
    em.getTransaction().begin();
    Student st = new Student();
    st = em.find(Student.class, studentTest.getIdStudent());
    Query q = em.createQuery("select ct from Catalog ct ");
    List<Catalog> ct = new ArrayList<Catalog>();
    ct = (List<Catalog>) q.getResultList();
    assertEquals(ct.size(), 3);
    assertTrue(ct.equals(st.getCatalog()));
    em.getTransaction().commit();
    em.close();
  }
View Full Code Here

    em.persist(g);

    int idGr = g.getIdGrupa();

    Student studentTest = new Student();
    studentTest.setIdGrupa(idGr);
    studentTest.setAnStudiu(anStudiuTest);
    studentTest.setEmail(emailTest);
    studentTest.setNrMatricol(numarMatricolTest);
    studentTest.setNume(numeTest);
    studentTest.setPrenume(prenumeTest);
    g.getStudenti().add(studentTest);
    em.persist(g);
    Query q = em.createNativeQuery("SELECT student.studenti_id_grupa  FROM Student WHERE student.studenti_id_grupa=?1")
        .setParameter(1, idGr);
    List st = q.getResultList();
    q = em.createQuery("select s from Student s");
    Student s = new Student();
    s = (Student) q.getSingleResult();
    assertEquals(st.size(), 1);
    Grupa g1 = new Grupa();
    g1.setNumeGrupa(numeGrupaTest1);
    em.persist(g1);
View Full Code Here

    int anStudiuTest = 2;
    String emailTest = "email";
    String numarMatricolTest = "1";
    String numeTest = "numeStudentTest";
    String prenumeTest = "prenumeStudentTest";
    Student s = new Student();
    s.setIdGrupa(1);
    s.setAnStudiu(anStudiuTest);
    s.setEmail(emailTest);
    s.setNrMatricol(numarMatricolTest);
    s.setNume(numeTest);
    s.setPrenume(prenumeTest);
    return s;

  }
View Full Code Here

  }
  @Test
  public void testStudentRelation(){
    String numeGrupaTest = "GrupaTest";
    Grupa g = new Grupa();
    Student s = new Student();

    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    s=initTest1();
    g.setNumeGrupa(numeGrupaTest);
    g.getStudenti().add(s);
    em.persist(g);
    Query q = em.createQuery("select grT from Grupa grT ");
    Grupa grT1=new Grupa();
    grT1=(Grupa) q.getSingleResult();
    assertTrue("Nu a fost introdus in grupa","GrupaTest".equals(grT1.getNumeGrupa()));
     q = em.createQuery("select st from Student st where st.nume='numeStudentTest' ");
    Student st = new Student();
    st = (Student) q.getSingleResult();
    assertTrue("Nu a fost introdus in student","numeStudentTest".equals(st.getNume()));
   
    em.getTransaction().commit();
  }
View Full Code Here

        em.persist(g);
        idGr = g.getIdGrupa();
        final int n=3;
        final int temp=1;
        for (int i = 0; i < n; i++) {
            Student s = new Student();
            s.setIdGrupa(0);
            s.setAnStudiu(temp);
            s.setEmail("email");
            s.setNrMatricol(String.valueOf(temp));
            s.setNume("Student_" + i);
            s.setPrenume("FacultateS_" + i);
            g.getStudenti().add(s);
         
            em.persist(g);
        }
       
View Full Code Here

    int nota=8;
    int nrPrezente=7;
     EntityManager em = emf.createEntityManager();
     Catalog c=new Catalog();
   
     Student s=new Student();
    
     c.setDataNotei(data);
     c.setIdObiect(idObiectTest);
     c.setIdStudent(idStudentTest);
     c.setNota(nota);
     c.setNrPrezente(nrPrezente);
     s.getCatalog().add(c);
       em.getTransaction().begin();
       em.persist(s);
      
       em.getTransaction().commit();
       int dataTest=(int) em.createNativeQuery("select catalog.id_student from catalog, student where catalog.catalog_id_student=student.id_student").getSingleResult();
View Full Code Here

TOP

Related Classes of org.jpa.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.