Bug 1035733 - Example 5.8. Using Projection Instead of Returning the Full Domain Object, code snippet should be changed
Summary: Example 5.8. Using Projection Instead of Returning the Full Domain Object, co...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Data Grid 6
Classification: JBoss
Component: Documentation
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: GA
: 6.2.0
Assignee: Misha H. Ali
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-28 10:59 UTC by Vitalii Chepeliuk
Modified: 2014-01-16 00:01 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Build Name: 14318, Infinispan Query Guide-6.2-1 Build Date: 28-11-2013 19:29:01 Topic ID: 14307-537544 [Latest]
Last Closed: 2014-01-16 00:01:18 UTC
Type: Bug


Attachments (Terms of Use)

Description Vitalii Chepeliuk 2013-11-28 10:59:17 UTC
Title: Projection

Describe the issue:
org.infinispan.query.FullTextQuery query = 
    s.createFullTextQuery( luceneQuery, Book.class );
query.setProjection( "id", "summary", "body", "mainAuthor.name" );
List results = query.list();
Object[] firstResult = (Object[]) results.get(0);
Integer id = firstResult[0];
String summary = firstResult[1];
String body = firstResult[2];
String authorName = firstResult[3];

Suggestions for improvement:
       org.infinispan.query.dsl.QueryFactory qf = Search.getSearchManager(cache).getQueryFactory();
        org.infinispan.query.dsl.Query query = qf.from(Book.class)
                        .setProjection("id", "summary", "body", "mainAuthor.name")
                        .orderBy("id", SortOrder.ASC)
                        .build();
        List results = query.list();
        Object[] firstResult = (Object[]) results.get(0);
        Integer id = firstResult[0];
        String summary = firstResult[1];
        String body = firstResult[2];
        String authorName = firstResult[3];
Additional information:

Comment 2 Vitalii Chepeliuk 2013-11-28 11:28:53 UTC
I thing I was mistaken in first case
Suggestions for improvement now are
     SearchManager searchManager = Search.getSearchManager(cache);
      CacheQuery cacheQuery = searchManager.getQuery(luceneQuery, Book.class);
      cacheQuery.projection("id", "summary", "body", "mainAuthor.name");
      List results = cacheQuery.list();
      Object[] firstResult = (Object[]) results.get(0);
      Integer id = firstResult[0];
      String summary = firstResult[1];
      String body = firstResult[2];
      String authorName = firstResult[3];

Comment 4 Misha H. Ali 2014-01-16 00:01:18 UTC
The fix for this bug is now generally released and available here:

https://access.redhat.com/site/documentation/en-US/Red_Hat_JBoss_Data_Grid/6.2/index.html


Note You need to log in before you can comment on or make changes to this bug.