if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { toOne.setFetchMode( FetchMode.JOIN ); toOne.setLazy( false ); toOne.setUnwrapProxy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { toOne.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed on ToOne associations" ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { collection.setFetchMode( FetchMode.JOIN ); collection.setLazy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { collection.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { collection.setFetchMode( FetchMode.SELECT ); collection.setSubselectLoadable( true ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
private void applyFetchMode(Root<T> root) { for (Field field : getDomainClass().getDeclaredFields()) { Fetch fetch = field.getAnnotation(Fetch.class); if (fetch != null && fetch.value() == FetchMode.JOIN) { root.fetch(field.getName(), JoinType.LEFT); } } }
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { toOne.setFetchMode( FetchMode.JOIN ); toOne.setLazy( false ); toOne.setUnwrapProxy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { toOne.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed on ToOne associations" ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
boolean isFetchOfTypeJoinPresent(Field field) { Annotation annotation = field.getAnnotation(Fetch.class); if (annotation instanceof Fetch) { Fetch fetch = (Fetch) annotation; return FetchMode.JOIN == fetch.value(); } return false; }
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { collection.setFetchMode( FetchMode.JOIN ); collection.setLazy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { collection.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { collection.setFetchMode( FetchMode.SELECT ); collection.setSubselectLoadable( true ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
@Override protected <S extends T> TypedQuery<S> getQuery(Specification<S> spec, Class<S> domainClass, Sort sort) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<S> query = builder.createQuery(domainClass); Root<S> root = applySpecificationToCriteria(spec, domainClass, query); query.select(root); applyFetchMode(root); if (sort != null) { query.orderBy(toOrders(sort, root, builder)); } return applyRepositoryMethodMetadata(em.createQuery(query)); } private void applyFetchMode(Root<? extends T> root) { applyFetchMode(root, getDomainClass()); } private void applyFetchMode(FetchParent<?, ?> root, Class<?> clazz) { for (Field field : clazz.getDeclaredFields()) { Fetch fetch = field.getAnnotation(Fetch.class); if (fetch != null && fetch.value() == FetchMode.JOIN) { FetchParent<?, ?> descent = root.fetch(field.getName(), JoinType.LEFT); applyFetchMode(descent, field.getType()); } } }
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { toOne.setFetchMode( FetchMode.JOIN ); toOne.setLazy( false ); toOne.setUnwrapProxy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { toOne.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed on ToOne associations" ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { toOne.setFetchMode( FetchMode.JOIN ); toOne.setLazy( false ); toOne.setUnwrapProxy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { toOne.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed on ToOne associations" ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { toOne.setFetchMode( FetchMode.JOIN ); toOne.setLazy( false ); toOne.setUnwrapProxy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { toOne.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed on ToOne associations" ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { collection.setFetchMode( FetchMode.JOIN ); collection.setLazy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { collection.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { collection.setFetchMode( FetchMode.SELECT ); collection.setSubselectLoadable( true ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { collection.setFetchMode( FetchMode.JOIN ); collection.setLazy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { collection.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { collection.setFetchMode( FetchMode.SELECT ); collection.setSubselectLoadable( true ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
toOne.setUnwrapProxy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { toOne.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed on ToOne associations" ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { collection.setFetchMode( FetchMode.JOIN ); collection.setLazy( false ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { collection.setFetchMode( FetchMode.SELECT ); else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { collection.setFetchMode( FetchMode.SELECT ); collection.setSubselectLoadable( true ); throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );