@Override public <T> IdentifierLoadAccess<T> byId(Class<T> entityClass) { return delegate.byId( entityClass ); }
@Override public IdentifierLoadAccess byId(String entityName) { return delegate.byId( entityName ); }
@After public void dropData() { inTransaction( session -> { final Customer customer = session.byId( Customer.class ).load( 1 ); if ( customer != null ) { session.delete( customer ); } } ); } }
@Override public IdentifierLoadAccess byId(String entityName) { return delegate.byId( entityName ); }
@Override public <T> IdentifierLoadAccess<T> byId(Class<T> entityClass) { return delegate.byId( entityClass ); }
private static Object executeLoad(EntityInfo entityInfo, SessionImplementor session) { Object maybeProxy; if ( areDocIdAndEntityIdIdentical( entityInfo, session ) ) { // be sure to get an initialized object but save from ObjectNotFoundException and EntityNotFoundException maybeProxy = session.byId( entityInfo.getType().getPojoType() ).load( entityInfo.getId() ); } else { Criteria criteria = new CriteriaImpl( entityInfo.getType().getName(), (SharedSessionContractImplementor) session ); criteria.add( Restrictions.eq( entityInfo.getIdName(), entityInfo.getId() ) ); try { maybeProxy = criteria.uniqueResult(); } catch (HibernateException e) { // FIXME should not raise an exception but return something like null // FIXME this happens when the index is out of sync with the db) throw new SearchException( "Loading entity of type " + entityInfo.getType().getName() + " using '" + entityInfo.getIdName() + "' as document id and '" + entityInfo.getId() + "' as value was not unique" ); } } return maybeProxy; }