Bug 527083 - The method is ambiguous for the type for eclipse Oxygen
Summary: The method is ambiguous for the type for eclipse Oxygen
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: APT (show other bugs)
Version: 4.7   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Generic inbox for the JDT-APT component CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-09 14:57 EST by mack lescano CLA
Modified: 2017-11-09 14:57 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mack lescano CLA 2017-11-09 14:57:47 EST
I have these classes

public class ProjectableSpecificationExecutorImpl<T, ID extends Serializable> 
	extends SimpleJpaRepository<T, ID> implements ProjectableSpecificationExecutor<T, ID>
	
	
	@Override
	public Page<T> findAll(NamedParamSpecification<T> spec, Pageable pageable) {
		TypedQuery<T> query = getQuery(spec, pageable);
		if (spec != null) {
			for (Entry<String, Object> entryParam : spec.getParameters().entrySet()) {
				query.setParameter(entryParam.getKey(), entryParam.getValue());
			}
		}
		return pageable == null ? new PageImpl<T>(query.getResultList()) : readPage(query, pageable, spec);
	}

	
	protected Page<T> readPage(TypedQuery<T> query, Pageable pageable, NamedParamSpecification<T> spec) {
		return readPage(query, getDomainClass(), pageable, spec);
	}
	
	protected <S extends T> Page<S> readPage(TypedQuery<S> query, Class<S> domainClass, Pageable pageable,
			NamedParamSpecification<S> spec) {

		query.setFirstResult(pageable.getOffset());
		query.setMaxResults(pageable.getPageSize());

		Long total = executeCountQuery(getCountQuery(spec, domainClass));
		List<S> content = total > pageable.getOffset() ? query.getResultList() : Collections.<S> emptyList();

		return new PageImpl<S>(content, pageable, total);
	}
}


@NoRepositoryBean
public interface ProjectableSpecificationExecutor<T, ID extends Serializable> extends JpaSpecificationExecutor<T> {

	Page<T> findAll(NamedParamSpecification<T> spec, Pageable pageable);

}


public class SimpleJpaRepository<T, ID extends Serializable>
		implements JpaRepository<T, ID>, JpaSpecificationExecutor<T> {
		
	/**
	 * Reads the given {@link TypedQuery} into a {@link Page} applying the given {@link Pageable} and
	 * {@link Specification}.
	 *
	 * @param query must not be {@literal null}.
	 * @param spec can be {@literal null}.
	 * @param pageable can be {@literal null}.
	 * @return
	 */
	protected Page<T> readPage(TypedQuery<T> query, Pageable pageable, Specification<T> spec) {
		return readPage(query, getDomainClass(), pageable, spec);
	}

	/**
	 * Reads the given {@link TypedQuery} into a {@link Page} applying the given {@link Pageable} and
	 * {@link Specification}.
	 *
	 * @param query must not be {@literal null}.
	 * @param domainClass must not be {@literal null}.
	 * @param spec can be {@literal null}.
	 * @param pageable can be {@literal null}.
	 * @return
	 */
	protected <S extends T> Page<S> readPage(TypedQuery<S> query, Class<S> domainClass, Pageable pageable,
			Specification<S> spec) {

		query.setFirstResult(pageable.getOffset());
		query.setMaxResults(pageable.getPageSize());

		Long total = executeCountQuery(getCountQuery(spec, domainClass));
		List<S> content = total > pageable.getOffset() ? query.getResultList() : Collections.<S> emptyList();

		return new PageImpl<S>(content, pageable, total);
	}
}

The eclipse compiler is giving an error in the line "return readPage(query, getDomainClass(), pageable, spec);" with this message: 
The method readPage(TypedQuery<T>, Class<T>, Pageable, NamedParamSpecification<T>) is ambiguous for the type ProjectableSpecificationExecutorImpl<T,ID>

However, the compiler javac8 doesn't have problems, it compiles cleanly.

Regards


-- Configuration Details --
Product: Eclipse 4.7.0.20170620-1800 (org.eclipse.epp.package.jee.product)Installed Features:
 org.eclipse.jdt 3.13.0.v20170612-0950
Versioning Plugin:
 org.eclipse.platform 4.7.0.v20170612-1255