CreateCriteria with projections does not select all columns

前端 未结 2 754
温柔的废话
温柔的废话 2021-01-15 03:50

My Question is exactly like Grails Projections not returning all properties and not grouped

I have a following criteria

def sharedDocumentsInstance         


        
相关标签:
2条回答
  • 2021-01-15 03:53

    For the sake of those still having this issue; Remove the provided params object on the list method. So the criteria query above becomes:

    def sharedDocumentsInstanceList = SharedDocuments.createCriteria().list {
        createAlias('receiver', 'r')
        createAlias('author', 'a')
        eq("r.id",session.uid)  
        projections {
            groupProperty("a.id")
            property("a.firstName","firstName")
            property("a.lastName","lastName")
            property("a.emailAddress","email")
        }
        maxResults(params.max)
        firstResult(params.offset)
        order(params.sort, params.order)
    }
    
    0 讨论(0)
  • 2021-01-15 03:53
        projections{                
            author {
               groupProperty("id")
               property("firstName","firstName")
               property("lastName","lastName")
               property("emailAddress","email")
            }
        }
    

    Would using the above approach yield different results? Just a thought...

    0 讨论(0)
提交回复
热议问题