use of javax.persistence.EntityTransaction in project Truck-Factor by aserg-ufmg.
the class NewFileInfoDAO method filterAndUpdateFilesInfo.
// public void update(FileInfo o){
// FileInfo persistedProject = this.em.find(FileInfo.class, o.getId());
// if (persistedProject != null){
// persistedProject.setFiltered(o.getFiltered());
// persistedProject.setFilterInfo(o.getFilterInfo());
// persistedProject.setMode(o.getMode());
// persistedProject.setPath(o.getPath());
// persistedProject.setSha(o.getSha());
// persistedProject.setSize(o.getSize());
// persistedProject.setType(o.getType());
// persistedProject.setLanguage(o.getLanguage());
// super.merge(persistedProject);
// }
// }
// public List<String> getPathsOfNotFilteredProjectFiles(String projectName){
// String custom = "";
//
// String hql = "SELECT fi.path FROM projectinfo_fileinfo pi_fi "
// + "JOIN projectinfo pi ON pi_fi.projectinfo_fullname = pi.fullname "
// + "JOIN newfileinfo nfi on pi_fi.files_id = nfi.id "
// + "WHERE pi.fullname = \'"+projectName+"\' AND nfi.filtered = 'FALSE' "
// + ";";
//
// Query q = em.createNativeQuery(hql);
// return q.getResultList();
//
// }
public int filterAndUpdateFilesInfo(String whereClauses, String filterStamp) {
String custom = "";
String hql = "UPDATE newfileinfo AS fi " + "SET filtered = \'TRUE\', filterinfo = \'" + filterStamp + "\' " + "WHERE " + whereClauses + ";";
Query q = em.createNativeQuery(hql);
int rows = 0;
EntityTransaction tx = this.em.getTransaction();
try {
tx.begin();
rows = q.executeUpdate();
tx.commit();
} catch (RuntimeException e) {
if (tx != null && tx.isActive())
tx.rollback();
throw e;
} finally {
this.em.clear();
}
return rows;
}
use of javax.persistence.EntityTransaction in project Truck-Factor by aserg-ufmg.
the class NewFileInfoDAO method removeFilterAndUpdateFilesInfo.
public int removeFilterAndUpdateFilesInfo(String whereClauses, String filterStamp) {
String custom = "";
String hql = "UPDATE newfileinfo AS fi " + "SET filtered = \'FALSE\', filterinfo = \'\' " + "WHERE " + whereClauses + ";";
Query q = em.createNativeQuery(hql);
int rows = 0;
EntityTransaction tx = this.em.getTransaction();
try {
tx.begin();
rows = q.executeUpdate();
tx.commit();
} catch (RuntimeException e) {
if (tx != null && tx.isActive())
tx.rollback();
throw e;
} finally {
this.em.clear();
}
return rows;
}
use of javax.persistence.EntityTransaction in project Truck-Factor by aserg-ufmg.
the class NewFileInfoDAO method filterAndUpdateFilesInfoByLanguage.
public int filterAndUpdateFilesInfoByLanguage(String whereClauses, String filterStamp) {
String custom = "";
String hql = "UPDATE newfileinfo AS fi " + "SET filtered = \'TRUE\', filterinfo = \'" + filterStamp + "\' " + "FROM projectinfo AS pi " + "WHERE pi.fullname = fi.repositoryname AND " + whereClauses + ";";
Query q = em.createNativeQuery(hql);
int rows = 0;
EntityTransaction tx = this.em.getTransaction();
try {
tx.begin();
rows = q.executeUpdate();
tx.commit();
} catch (RuntimeException e) {
if (tx != null && tx.isActive())
tx.rollback();
throw e;
} finally {
this.em.clear();
}
return rows;
}
use of javax.persistence.EntityTransaction in project Truck-Factor by aserg-ufmg.
the class NewFileInfoDAO method classifierAndUpdateFilesInfo.
public int classifierAndUpdateFilesInfo(String whereClauses, FileType fileType) {
String custom = "";
String hql = "UPDATE newfileinfo AS fi " + "SET kind = \'" + fileType + "\' " + "WHERE " + whereClauses + ";";
Query q = em.createNativeQuery(hql);
int rows = 0;
EntityTransaction tx = this.em.getTransaction();
try {
tx.begin();
rows = q.executeUpdate();
tx.commit();
} catch (RuntimeException e) {
if (tx != null && tx.isActive())
tx.rollback();
throw e;
} finally {
this.em.clear();
}
return rows;
}
use of javax.persistence.EntityTransaction in project hibernate-orm by hibernate.
the class EmbeddableWithNoDeclaredDataTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
EntityWithEmbeddableWithNoDeclaredData entity = new EntityWithEmbeddableWithNoDeclaredData();
entity.setName("Entity 1");
entity.setValue(new EmbeddableWithNoDeclaredData(84));
EntityTransaction tx = em.getTransaction();
tx.begin();
em.persist(entity);
tx.commit();
em.close();
id = entity.getId();
}
Aggregations