Friday, 15 January 2010

mysql - incorrect sql query created using setMaxResults with native query -


I have this code, where I am creating a native query and while executing native queries, I use the setMaxResults method Has been doing.

  list & lt ;? & Gt; ResultList = getEntityManager (speedwingCustId, loggedInUserId list) .createNativeQuery (statement) .setMaxResults (Integer.MAX_VALUE) .getResultList ();  

This is your statement before the above code:

  (Selection IQV.VERSION_ID VERSION_ID as ITEM_QUERY_VIEW IQV Where AVAILABLE_VALUE_ID (15,611) and EQUIPMENT_AVAILABILITY_ID = 1 And in region_id (5, 8, 10, 14, 21, 20, 23, 24, 26, 35, 33, 39, 45, 55, 54, 53, 52, 63, 62, 61, 68, 71, 64, COUNT (DISTINCT (AVAILABLE_VALUE_ID)) = 1)  

of the group by VERSION_ID (65, 76, 72) and VEHICLE_TYPE_ID (1, 2, 3, 4, 5, 6, 7) My query is during this execution:

  Hibernate: (SE Top (?) LECT IQV.VERSION_ID as ITEM_QUERY_VIEW IQV from VERSION_ID where AVAILABLE_VALUE_ID IN (15611) and EQUIPMENT_AVAILABILITY_ID = 1 more REGION_ID IN (5, 8, 10, 14, 2 1, 20, 23, 24, 26, 35, 33, 39, 45, 55, 54, 53, 52, 63, 62, 61, 68, 71, 64, 65, 76, 72) and VEHICLE_TYPE_ID IN (1, 2, 3, 4, 5, 6, 7) VERSION_ID HOWING C OUNT (DISTINCT (AVAILABLE_VALUE_ID)) by group = 1)  

I am using MSSQL server and JPA.

Why do you set Integer.MAX_VALUE to MaxResults ()? It does not mean try to extract it or pass a meaningful number, for example, setMaxResults (30).


No comments:

Post a Comment