List of usage examples for org.hibernate Session clear
void clear();
From source file:au.gov.naa.digipres.spyd.dao.hibernate.HibernateItemRecordDAO.java
License:Open Source License
@Override public void removeItemRecord(ItemRecord itemRecord) { logger.fine("Removing Item Record"); Session session = HibernateUtil.getSession(); session.delete(itemRecord);/*from ww w .j a v a 2 s . co m*/ session.flush(); session.clear(); logger.fine("Item Record Removed."); }
From source file:au.org.theark.phenotypic.model.dao.PhenotypicDao.java
License:Open Source License
public void processPhenoCollectionsWithTheirDataToInsertBatch( List<PhenoDataSetCollection> phenoCollectionsWithTheirDataToInsert, Study study) { Session session = getSession(); // int count = 0; for (PhenoDataSetCollection collectionToInsert : phenoCollectionsWithTheirDataToInsert) { //TODO : investigate more efficient way to deal with null parent entity Set<PhenoDataSetData> dataToSave = collectionToInsert.getPhenoDataSetData(); collectionToInsert.setPhenoDataSetData(new HashSet<PhenoDataSetData>()); session.save(collectionToInsert); session.refresh(collectionToInsert); for (PhenoDataSetData data : dataToSave) { data.setPhenoDataSetCollection(collectionToInsert); session.save(data);/* w w w . j av a 2 s . co m*/ } } session.flush(); session.clear(); }
From source file:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
/** * {@inheritDoc}//from w ww . j av a 2 s .com */ public void processPedigreeBatch(List<LinkSubjectPedigree> parentsToInsert, List<LinkSubjectTwin> twinsToInsert) { Session session = getSession(); int count = 0; for (LinkSubjectPedigree dataToInsert : parentsToInsert) { 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(); } } count = 0; for (LinkSubjectTwin dataToInsert : twinsToInsert) { 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:au.org.theark.study.model.dao.StudyDao.java
License:Open Source License
/** * {@inheritDoc}//from w w w . j a v a 2 s . c o m */ public void processSubjectAttachmentBatch(List<SubjectFile> subjectFiles) { Session session = getSession(); int count = 0; for (SubjectFile subjectFile : subjectFiles) { session.save(subjectFile); 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: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);// w w w. ja v a2 s .c o m 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!!!!!!!!!!!!!!"); // 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 T getByID(int id, Class clazz) { T item = null;//from w w w .j a va2 s .c om Session session = null; Transaction beginTransaction = null; try { session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); item = (T) session.get(clazz, id); session.flush(); session.clear(); beginTransaction.commit(); } catch (HibernateException ex) { ex.printStackTrace(); if (beginTransaction != null) { beginTransaction.rollback(); } } finally { if (session != null) { session.close(); } } return item; }
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. j a v a 2s. c om 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:autoancillarieslimited.hiberate.dao.AbstractDao.java
public List<T> getList(String tableName) { List<T> set = null;//from ww w. j a v a 2s. c o m Session session = null; Transaction beginTransaction = null; try { session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); set = session.createQuery("from " + tableName + "").list(); session.flush(); session.clear(); session.getTransaction().commit(); } catch (HibernateException ex) { ex.printStackTrace(); if (beginTransaction != null) { beginTransaction.rollback(); } } finally { if (session != null) { session.close(); } } return set; }
From source file:autoancillarieslimited.hiberate.dao.CustomerDAO.java
public Customer checkLogin(String email, String password) { Customer item = null;/* w w w. j a va 2s . c o m*/ Session session = null; Transaction beginTransaction = null; try { session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); item = (Customer) session .createQuery( "from Customer where Email like '" + email + "' AND PassWord like '" + password + "'") .uniqueResult(); session.flush(); session.clear(); beginTransaction.commit(); } catch (HibernateException ex) { ex.printStackTrace(); if (beginTransaction != null) { beginTransaction.rollback(); } } finally { if (session != null) { session.close(); } } return item; }
From source file:autoancillarieslimited.hiberate.dao.CustomerDAO.java
public boolean checkEmail(String email) { Customer item = null;/* ww w . ja va 2 s. co m*/ Session session = null; Transaction beginTransaction = null; try { session = HibernateUtil.getSessionFactory().openSession(); beginTransaction = session.beginTransaction(); item = (Customer) session.createQuery("from Customer where Email like '" + email + "'").uniqueResult(); session.flush(); session.clear(); beginTransaction.commit(); } catch (HibernateException ex) { ex.printStackTrace(); if (beginTransaction != null) { beginTransaction.rollback(); } } finally { if (session != null) { session.close(); } } if (item != null) { return false; } return true; }