return catalog;
}
public static void aplliedAction(List<CatalogBean> modificari) {
Obiect ol = new Obiect();
Student st=new Student();
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")