Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projections in MongoDB #205

Closed
ufasoli opened this issue Jul 30, 2012 · 4 comments
Closed

Projections in MongoDB #205

ufasoli opened this issue Jul 30, 2012 · 4 comments
Milestone

Comments

@ufasoli
Copy link

@ufasoli ufasoli commented Jul 30, 2012

It would be great if the MongoDBQuery could support projections as the HibernateQuery does as explained in this post

According to the Mongo offcial documentation much better performances can be achieved when selecting only relevant fields in a query MongoDB Documentation (Optimization # 3: Select only relevant fields)

Best regards

Ulises Fasoli

timowest added a commit that referenced this issue Nov 28, 2012
@timowest
Copy link
Member

@timowest timowest commented Nov 28, 2012

Projections can now be used via the overloaded list, singleResult, uniqueResult and listResults methods. The projection type is the same as for the other methods to be consistent with previous Mongodb query behaviour.

e.g. User with only firstName and lastName mapped

User u = query.where(user.firstName.eq("Jaakko")).singleResult(user.firstName, user.lastName);
@timowest
Copy link
Member

@timowest timowest commented Jan 13, 2013

Released in 3.0.0.BETA1

@timowest timowest closed this Jan 13, 2013
@btiernay
Copy link

@btiernay btiernay commented Feb 18, 2014

Does this support nested projections? For example, a single field from an array property?

@btiernay
Copy link

@btiernay btiernay commented Feb 19, 2014

I couldn't find an example that illustrates this use case. Am I overlooking something? Thanks!

@timowest timowest added this to the 3.0.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants