Refine search
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
public Long createAndStorePerson(Person person) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction(); Long personId = (Long)session.save(person); session.getTransaction().commit(); return personId; }
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<888888; i++ ) { TableA record = new TableA(); record.setXXXX(); session.save(record) if ( i % 50 == 0 ) { //50, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
public Long createAndStorePerson(Person person) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction(); Long personId = (Long)session.save(person); session.getTransaction().commit(); return personId; }
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
public Long addPersonToAccount(Long personId, Account account) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction(); Person aPerson = (Person)session.load(Person.class, personId); account.setPerson(aPerson); Long accountId = (Long)session.save(account); session.getTransaction().commit(); return accountId; }
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
public Long addPersonToAccount(Long personId, Account account) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction(); Person aPerson = (Person)session.load(Person.class, personId); account.setPerson(aPerson); Long accountId = (Long)session.save(account); session.getTransaction().commit(); return accountId; }
private DestinationEntity createDestination(FromEntity fromEntity, String fullName) { final DestinationEntity destinationEntity = new DestinationEntity( fromEntity, fullName ); Session session = openSession(); session.getTransaction().begin(); session.save( destinationEntity ); session.getTransaction().commit(); session.close(); return destinationEntity; }
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
public Long createHolidayCalendar() { Session session = sessionFactory.getCurrentSession(); session.beginTransaction(); // delete all existing calendars List calendars = session.createQuery("from HolidayCalendar").setCacheable(true).list(); for (ListIterator li = calendars.listIterator(); li.hasNext(); ) { session.delete(li.next()); } HolidayCalendar calendar = new HolidayCalendar(); calendar.init(); Long calendarId = (Long)session.save(calendar); session.getTransaction().commit(); return calendarId; }
private ParentWithCollection createParentWithNullChildren(String parentName) { Session s = openSession(); Transaction tx = s.beginTransaction(); ParentWithCollection parent = createParent( parentName ); s.save( parent ); tx.commit(); s.close(); return parent; }
public Long createHolidayCalendar() { Session session = sessionFactory.getCurrentSession(); session.beginTransaction(); // delete all existing calendars List calendars = session.createQuery("from HolidayCalendar").setCacheable(true).list(); for (ListIterator li = calendars.listIterator(); li.hasNext(); ) { session.delete(li.next()); } HolidayCalendar calendar = new HolidayCalendar(); calendar.init(); Long calendarId = (Long)session.save(calendar); session.getTransaction().commit(); return calendarId; }
@Test public void testAfterDelete() throws Exception { Session s = openSession(); s.beginTransaction(); Foo foo = new Foo(); s.save(foo); s.flush(); s.delete(foo); s.save(foo); s.delete(foo); s.getTransaction().commit(); s.close(); }
public Long createAndStorePerson(String firstName, String lastName) { Session session = sessionFactory.getCurrentSession(); session.beginTransaction(); Person person = new Person(); person.setFirstname(firstName); person.setLastname(lastName); Long personId = (Long)session.save(person); session.getTransaction().commit(); return personId; }