All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jinq.jpa.transform.DistinctTransform Maven / Gradle / Ivy

The newest version!
package org.jinq.jpa.transform;

import org.jinq.jpa.jpqlquery.JPQLQuery;
import org.jinq.jpa.jpqlquery.SelectOnly;

public class DistinctTransform extends JPQLNoLambdaQueryTransform
{
   public DistinctTransform(JPQLQueryTransformConfiguration config)
   {
      super(config);
   }
   
   public  JPQLQuery apply(JPQLQuery query, SymbExArgumentHandler parentArgumentScope) throws QueryTransformException
   {
      if (query.canDistinct())
      {
         SelectOnly select = (SelectOnly)query;
         
         // Create the new query, merging in the analysis of the method
         SelectOnly toReturn = (SelectOnly)select.shallowCopy();
         toReturn.isDistinct = true;
         
         return toReturn;
      }
      throw new QueryTransformException("Existing query cannot be transformed further");
   }
   
   @Override 
   public String getTransformationTypeCachingTag()
   {
      return DistinctTransform.class.getName();
   }

}