List of usage examples for org.hibernate Session update
void update(Object object);
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
/** * Update the Study consent fo all LinkSubjectStudy's in the specified Study * /*from ww w . j av a 2 s .com*/ * @param study */ public void consentAllLinkSubjectsToStudy(Study study) { Session session = getSession(); Set<LinkSubjectStudy> linkSubjectStudyList = study.getLinkSubjectStudies(); for (Iterator<LinkSubjectStudy> iterator = linkSubjectStudyList.iterator(); iterator.hasNext();) { LinkSubjectStudy linkSubjectStudy = (LinkSubjectStudy) iterator.next(); autoConsentLinkSubjectStudy(linkSubjectStudy); session.update(linkSubjectStudy); } }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
@Override public void processFieldsBatch(List<? extends ICustomFieldData> fieldsToUpdate, Study study, List<? extends ICustomFieldData> fieldsToInsert) { Session session = getSession(); int count = 0; for (ICustomFieldData dataToUpdate : fieldsToUpdate) { session.update(dataToUpdate); count++;// w w w . j a v a 2s . c o m // based on recommended hibernate practice of <prop key="hibernate.jdbc.batch_size">50</prop> if (count % 50 == 0) { log.info("\n\n\n\n\n\n\n\n\nflush!!!!!!!!!!!!!!"); // TODO Evaluate why batch not working. hints: may be identity/id generation related. // Will revisit after all batch work done session.flush(); session.clear(); } } count = 0; for (ICustomFieldData dataToInsert : fieldsToInsert) { session.save(dataToInsert); count++; // based on recommended hibernate practice of <prop key="hibernate.jdbc.batch_size">50</prop> if (count % 50 == 0) { log.info("\n\n\n\n\n\n\n\n\nflush!!!!!!!!!!!!!!"); session.flush(); session.clear(); } } session.flush(); session.clear(); }
From source file:autoancillarieslimited.hiberate.dao.AbstractDao.java
@Override public boolean update(T object) { Session session = null; Transaction beginTransaction = null; try {/*from w w w . jav a 2 s.com*/ session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); session.update(object); session.flush(); session.clear(); beginTransaction.commit(); } catch (HibernateException ex) { ex.printStackTrace(); if (beginTransaction != null) { beginTransaction.rollback(); } } finally { if (session != null) { session.close(); } } return true; }
From source file:automatedbillingsoftware_DA.Categories_DA.java
public void updateCategory(Categories cat) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); cat.setCatModifiedDate(new Date()); // System.out.println("update =>" + cat.getCatName()); // String name=cat.getCatName(); // cat = (Categories) session.load(Categories.class, cat.getCatid()); //cat.setCatName(name); session.update(cat); // session.flush(); beginTransaction.commit();// w ww . j a v a2 s .com }
From source file:automatedbillingsoftware_DA.Categories_DA.java
public void deleteCategory(Categories cat) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); cat.setCatModifiedDate(new Date()); cat.setStatus(0);/*ww w. j a v a2s. c om*/ // cat = (Categories) session.load(Categories.class, cat.getCatid()); //session.delete(cat); //session.flush(); session.update(cat); beginTransaction.commit(); }
From source file:automatedbillingsoftware_DA.ChallanDA.java
public Challan updateChallan(Challan challan) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.openSession(); Transaction beginTransaction = session.beginTransaction(); session.update(challan); beginTransaction.commit();/*from w ww.ja va2 s. c o m*/ return challan; }
From source file:automatedbillingsoftware_DA.ChallanDA.java
public ChallanGenerated updateChallanGen(ChallanGenerated challan) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); session.update(challan); session.flush();//from w w w .j a v a 2 s.c o m beginTransaction.commit(); return challan; }
From source file:automatedbillingsoftware_DA.ChallanDA.java
public void deleteChallan(int id) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); Query query = session.createQuery("from Challan where status=:status AND id=:id"); query.setParameter("status", 1); query.setParameter("id", id); List<Challan> challanList = (List<Challan>) query.list(); Challan challan = challanList.get(0); challan.setStatus(0);/*from ww w.j a v a2s. co m*/ session.update(challan); beginTransaction.commit(); }
From source file:automatedbillingsoftware_DA.CompanyDetailsDA.java
public void updateCurrentCompany(Company comp) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); session.beginTransaction();// w w w. j a v a 2s .c o m Query query = session.createQuery("from Company c where c.companyId=:id"); query.setParameter("id", UserSession.getCompany().getCompanyId()); Company com = (Company) query.list().get(0); com.setAddress(comp.getAddress()); com.setCompanyName(comp.getCompanyName()); com.setCountry(comp.getCountry()); com.setDateOfInsertion(comp.getDateOfInsertion()); com.setEmail(comp.getEmail()); com.setLogo(comp.getLogo()); com.setName(comp.getName()); com.setPanNo(comp.getPanNo()); com.setPassword(comp.getPassword()); com.setPhone(comp.getPhone()); com.setStatus(1); com.setTax(comp.getTax()); com.setVatNo(comp.getVatNo()); com.setWebsite(comp.getWebsite()); session.update(com); UserSession.setCompany(com); session.getTransaction().commit(); }
From source file:automatedbillingsoftware_DA.InvoiceReport_DA.java
public InvoiceReport updateInvoiceReport(InvoiceReport invReport) { SessionFactory sessionFactory = HibernateUtils.getLocSessionFactory(); Session session = sessionFactory.getCurrentSession(); Transaction beginTransaction = session.beginTransaction(); session.update(invReport); beginTransaction.commit();// w w w.jav a 2 s . com return invReport; }