Buggy code:
public abstract class AbstractQueryBuilder < T , X extends QueryBuilder < T , X > > extends AbstractBaseQueryBuilder < T , X > implements QueryBuilder < T , X > { private boolean createdPaginatedBuilder = false ; protected AbstractQueryBuilder ( AbstractQueryBuilder < T , ? extends QueryBuilder < T , ? > > builder ) { } public AbstractQueryBuilder ( CriteriaBuilderFactoryImpl cbf , EntityManager em , Class < T > clazz , String alias ) { } @ Override public List < T > getResultList ( ) { } @ Override public T getSingleResult ( ) { } @ Override public PaginatedCriteriaBuilder < T > page ( int firstRow , int pageSize ) { } @ Override public PaginatedCriteriaBuilder < T > page ( Object entityId , int pageSize ) { } @ Override public PaginatedCriteriaBuilder < T > page ( KeySet keySet , int firstRow , int pageSize ) { } @ Override public PaginatedCriteriaBuilder < T > page ( KeySet keySet , Object entityId , int pageSize ) { } private void checkEntityId ( Object entityId ) { if ( entityId == null ) { throw new IllegalArgumentException ( "Invalid<seq2seq4repair_space>null<seq2seq4repair_space>entity<seq2seq4repair_space>id<seq2seq4repair_space>given" ) ; } <START_BUG> EntityType < ? > entityType = em . getMetamodel ( ) . entity ( fromClazz ) ; <END_BUG> Class < ? > idType = entityType . getIdType ( ) . getJavaType ( ) ; if ( ! ( idType . isInstance ( entityId ) ) ) { throw new IllegalArgumentException ( ( ( ( ( ( ( "The<seq2seq4repair_space>type<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>given<seq2seq4repair_space>entity<seq2seq4repair_space>id<seq2seq4repair_space>'" + ( entityId . getClass ( ) . getName ( ) ) ) + "'<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>an<seq2seq4repair_space>instance<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>expected<seq2seq4repair_space>id<seq2seq4repair_space>type<seq2seq4repair_space>'" ) + ( idType . getName ( ) ) ) + "'<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>entity<seq2seq4repair_space>class<seq2seq4repair_space>'" ) + ( fromClazz . getName ( ) ) ) + "'" ) ) ; } } @ Override public X setParameter ( String name , Object value ) { } @ Override public X setParameter ( String name , Calendar value , TemporalType temporalType ) { } @ Override public X setParameter ( String name , Date value , TemporalType temporalType ) { } @ Override public < Y > SelectObjectBuilder < ? extends QueryBuilder < Y , ? > > selectNew ( Class < Y > clazz ) { } @ Override public < Y > SelectObjectBuilder < ? extends QueryBuilder < Y , ? > > selectNew ( Constructor < Y > constructor ) { } @ Override public < Y > QueryBuilder < Y , ? > selectNew ( ObjectBuilder < Y > objectBuilder ) { } private void checkFetchJoinAllowed ( ) { } @ Override public X fetch ( String path ) { } @ Override public X innerJoinFetch ( String path , String alias ) { } @ Override public X innerJoinFetchDefault ( String path , String alias ) { } @ Override public X leftJoinFetch ( String path , String alias ) { } @ Override public X leftJoinFetchDefault ( String path , String alias ) { } @ Override public X rightJoinFetch ( String path , String alias ) { } @ Override public X rightJoinFetchDefault ( String path , String alias ) { } @ Override public X join ( String path , String alias , JoinType type , boolean fetch ) { } @ Override public X joinDefault ( String path , String alias , JoinType type , boolean fetch ) { } private X join ( String path , String alias , JoinType type , boolean fetch , boolean defaultJoin ) { } @ Override public TypedQuery < T > getQuery ( ) { } void parameterizeQuery ( Query q ) { } @ Override public boolean containsParameter ( String name ) { } @ Override public boolean isParameterSet ( String name ) { } @ Override public Parameter < ? > getParameter ( String name ) { } @ Override public Set < ? extends Parameter < ? > > getParameters ( ) { } @ Override public Object getParameterValue ( String name ) { } @ Override public Metamodel getMetamodel ( ) { } @ Override public X groupBy ( String expression ) { } @ Override public X groupBy ( String ... paths ) { } @ Override public X distinct ( ) { } @ Override public CaseWhenBuilder < ? extends QueryBuilder < T , ? > > selectCase ( ) { } @ Override public CaseWhenBuilder < ? extends QueryBuilder < T , ? > > selectCase ( String alias ) { } @ Override public SimpleCaseWhenBuilder < ? extends QueryBuilder < T , ? > > selectSimpleCase ( String expression ) { } @ Override public SimpleCaseWhenBuilder < ? extends QueryBuilder < T , ? > > selectSimpleCase ( String expression , String alias ) { } @ Override public QueryBuilder < T , ? > select ( String expression ) { } @ Override public QueryBuilder < T , ? > select ( String expression , String alias ) { } @ Override public SubqueryInitiator < ? extends QueryBuilder < T , ? > > selectSubquery ( ) { } @ Override public SubqueryInitiator < ? extends QueryBuilder < T , ? > > selectSubquery ( String alias ) { } @ Override public SubqueryInitiator < ? extends QueryBuilder < T , ? > > selectSubquery ( String subqueryAlias , String expression ) { } @ Override public SubqueryInitiator < ? extends QueryBuilder < T , ? > > selectSubquery ( String subqueryAlias , String expression , String selectAlias ) { } }

Fix:
EntityType < ? > entityType = fromClazz ;