AbstractHibernateCurator { public E lockAndLoad(Serializable id) { return this.lockAndLoad(this.entityType, id); } AbstractHibernateCurator(Class<E> entityType); Class<E> entityType(); int getInBlockSize(); int getCaseBlockSize(); int getBatchBlockSize(); int getQueryParameterLimit(); E getSingleResult(TypedQuery<E> query); void enableFilter(String filterName, String parameterName, Object value); void enableFilterList(String filterName, String parameterName, Collection value); @Transactional E secureGet(Serializable id); @Transactional E get(Serializable id); @Transactional boolean exists(Serializable id); String getPrimaryKeyName(); @Transactional E create(E entity); @Transactional E create(E entity, boolean flush); CandlepinQuery<E> listAll(); CandlepinQuery<E> listAllByIds(Collection<? extends Serializable> ids); @SuppressWarnings("unchecked") @Transactional Page<List<E>> listAll(PageRequest pageRequest, boolean postFilter); @SuppressWarnings("unchecked") @Transactional Page<List<E>> listAll(PageRequest pageRequest); @SuppressWarnings("unchecked") Page<ResultIterator<E>> paginateResults(CandlepinQuery<E> query, PageRequest pageRequest); @SuppressWarnings("unchecked") @Transactional List<E> listByCriteria(Criteria query); @Transactional List<E> listByCriteria(CriteriaQuery<E> query); @SuppressWarnings("unchecked") @Transactional Page<List<E>> listByCriteria(Criteria query, PageRequest pageRequest, boolean postFilter); @SuppressWarnings("unchecked") @Transactional Page<List<E>> listByCriteria(Criteria c, PageRequest pageRequest); @Transactional Page<List<E>> listByCriteria(Root<E> root, CriteriaQuery<E> criteria, PageRequest pageRequest,
        int maxRecords); @Transactional void delete(E entity); @Transactional void bulkDelete(Collection<E> entities); void detach(E entity); void batchDetach(Collection<E> entities); @Transactional void bulkDeleteTransactional(Collection<E> entities); @Transactional E merge(E entity); @Transactional E saveOrUpdate(E entity); void flush(); void clear(); Session currentSession(); Session openSession(); EntityManager getEntityManager(); EntityTransaction getTransaction(); org.candlepin.util.Transactional<O> transactional(
        org.candlepin.util.Transactional.Action<O> action); @Transactional Collection<E> saveAll(Collection<E> entities, boolean flush, boolean evict); Collection<E> updateAll(Collection<E> entities, boolean flush, boolean evict); Iterable<E> saveOrUpdateAll(Iterable<E> entities, boolean flush, boolean evict); Collection<E> mergeAll(Collection<E> entities, boolean flush); void refresh(Iterable<E> entities); void refresh(E... entities); E evict(E entity); void evictAll(Iterable<E> collection); List<E> takeSubList(PageRequest pageRequest, List<E> results); Collection<E> lock(Iterable<E> entities); Collection<E> lock(E... entities); E lock(E entity); E lock(E entity, LockModeType lockMode); E lockAndLoad(Serializable id); Collection<E> lockAndLoad(Iterable<? extends Serializable> ids);  }
@Test public void testLockAndLoadWithSingleIdUsesCache() { Owner owner = this.createOwner("owner_key-1", "owner-1"); Owner output = this.testOwnerCurator.lockAndLoad(owner.getId()); assertSame(owner, output); }
@Test public void testLockAndLoadWithSingleIdDoesNotRevertPropertyChange() { Owner owner = this.createOwner("owner_key-1", "owner-1"); owner.setDisplayName("changed_name"); this.testOwnerCurator.lockAndLoad(owner.getId()); assertEquals("changed_name", owner.getDisplayName()); }
@Test public void testLockAndLoadWithSingleIdWithClassAndId() { Owner owner = this.createOwner("owner_key-1", "owner-1"); Owner output = this.testOwnerCurator.lockAndLoad(Owner.class, owner.getId()); assertEquals(owner, output); }
@Test public void testLockAndLoadWithSingleIdWithClassAndIdDoesNotRevertPropertyChange() { Owner owner = this.createOwner("owner_key-1", "owner-1"); owner.setDisplayName("changed_name"); this.testOwnerCurator.lockAndLoad(Owner.class, owner.getId()); assertEquals("changed_name", owner.getDisplayName()); }
@Test public void testLockAndLoadMultiId() { Owner owner1 = this.createOwner("owner_key-1", "owner-1"); Owner owner2 = this.createOwner("owner_key-2", "owner-2"); Owner owner3 = this.createOwner("owner_key-3", "owner-3"); Collection<String> input = Arrays.asList(owner1.getId(), owner2.getId(), owner3.getId()); Collection<Owner> output = this.testOwnerCurator.lockAndLoad(input); assertEquals(3, output.size()); for (Owner expected : Arrays.asList(owner1, owner2, owner3)) { boolean found = false; for (Owner owner : output) { if (expected.equals(owner)) { assertFalse(found); assertEquals(expected.getId(), owner.getId()); found = true; } } assertTrue(found, "expected entity was not found in output: " + expected.getId()); } }
@Test public void testLockAndLoadMultiIdDoesNotRevertPropertyChange() { Owner owner1 = this.createOwner("owner_key-1", "owner-1"); Owner owner2 = this.createOwner("owner_key-2", "owner-2"); Owner owner3 = this.createOwner("owner_key-3", "owner-3"); owner1.setDisplayName("name change 1"); owner2.setDisplayName("name change 2"); owner3.setDisplayName("name change 3"); Collection<String> input = Arrays.asList(owner1.getId(), owner3.getId()); Collection<Owner> output = this.testOwnerCurator.lockAndLoad(input); assertEquals(2, output.size()); assertTrue(output.contains(owner1)); assertFalse(output.contains(owner2)); assertTrue(output.contains(owner3)); assertEquals("name change 1", owner1.getDisplayName()); assertEquals("name change 2", owner2.getDisplayName()); assertEquals("name change 3", owner3.getDisplayName()); }
@Test public void testLockAndLoadMultiIdWithClassAndIds() { Owner owner1 = this.createOwner("owner_key-1", "owner-1"); Owner owner2 = this.createOwner("owner_key-2", "owner-2"); Owner owner3 = this.createOwner("owner_key-3", "owner-3"); Collection<String> input = Arrays.asList(owner1.getId(), owner2.getId(), owner3.getId()); Collection<Owner> output = this.testOwnerCurator.lockAndLoad(Owner.class, input); assertEquals(3, output.size()); for (Owner expected : Arrays.asList(owner1, owner2, owner3)) { boolean found = false; for (Owner owner : output) { if (expected.equals(owner)) { assertFalse(found); assertEquals(expected.getId(), owner.getId()); found = true; } } assertTrue(found, "expected entity was not found in output: " + expected.getId()); } }
@Test public void testLockAndLoadMultiIdWithClassAndIdsDoesNotRevertPropertyChange() { Owner owner1 = this.createOwner("owner_key-1", "owner-1"); Owner owner2 = this.createOwner("owner_key-2", "owner-2"); Owner owner3 = this.createOwner("owner_key-3", "owner-3"); owner1.setDisplayName("name change 1"); owner2.setDisplayName("name change 2"); owner3.setDisplayName("name change 3"); Collection<String> input = Arrays.asList(owner1.getId(), owner3.getId()); Collection<Owner> output = this.testOwnerCurator.lockAndLoad(Owner.class, input); assertEquals(2, output.size()); assertTrue(output.contains(owner1)); assertFalse(output.contains(owner2)); assertTrue(output.contains(owner3)); assertEquals("name change 1", owner1.getDisplayName()); assertEquals("name change 2", owner2.getDisplayName()); assertEquals("name change 3", owner3.getDisplayName()); }