Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Как выбирать только некоторые поля с Criteria API
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bugdog  
View profile   Translate to Translated (View Original)
 More options Jan 22 2011, 6:33 am
From: Bugdog <drpada...@googlemail.com>
Date: Sat, 22 Jan 2011 03:33:07 -0800 (PST)
Local: Sat, Jan 22 2011 6:33 am
Subject: Как выбирать только некоторые поля с Criteria API
Всем привет,

Делаю форум. Есть 2 доменных объекта - "Раздел" и "Тема".
Хочу выбрать с помощью Criteria API несколько самых новых тем (subjs),
принадлежащих разделу (dir).

Но мне нужны только Id темы и дата последнего сообщения, остальные
поля мне не нужны. На HQL у меня это легко бы получилось.

Читал http://www.grails.org/Hibernate+Criteria+Builder - Querying with
projections -  Projections to be used to customise the results....

List<Object[]> subjs = ForumSubj.createCriteria().list(max:
SubjTracker.MAX_HISTORY)
{
    eq("dir.id",dirId)
    projections
    {
          property("id")
          property("lastPostDate")
    }
    order("lastPostDate", "desc")

}

Вместо ожидаемой коллекции массивов из двух элементов я получаю просто
коллекцию доменных объектов ForumSubj. В этом-то и проблема.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »