google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

Add a way to limit loading of references to collections #301

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
For example, I have a class with field:

  @Reference(lazy = true)
  private Set<Sentence> sentences = new HashSet<Sentence>();

But when this gets large it tends to crash the JVM due to lack of memory. It 
would be useful to have an extra option in the annotation such as "limit = 100" 
to only load up the first 100 references from Mongo.

Original issue reported on code.google.com by Nic.and....@gmail.com on 13 Jul 2011 at 8:39

GoogleCodeExporter commented 9 years ago
This is too complicated, and will lead to bad/unexpected behavior in my opinion.

If you want this kind of control I suggest you resolve references manually 
using something like.

Set<Key<Sentence>> sentences....
Set<Sentences> getFirst100() {...}

Also, if you want to limit this you will be able to specify a field restriction 
($slice) when you query for the parent.

Original comment by scotthernandez on 13 Jul 2011 at 11:42

GoogleCodeExporter commented 9 years ago
This is equal to #138

Original comment by wuhaix...@gmail.com on 17 Aug 2011 at 12:39