Lazy Reference Collection Mapping

Upcoming Compass 2.1 M3 now has a new feature allowing for lazy loaded reference mapping in Compass when using it on top of collections. Reference mapping in Compass simply stores the relationship between one object and another (the ids), and many times there is no need to load all the references in advance while unmarshalling an object. Now, reference mappings on top of collections can be lazily loaded. Here is an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
@Searchable
public class Customer {
 
    @SearchableId
    private int id;
 
    @SearchableReference(lazy = Lazy.TRUE)
    private List<Order> orders;
}
 
@Searchable
public class Order {
 
    @SearchableId
    private int id;
}

6 Responses to “Lazy Reference Collection Mapping”

  1. enguzekli Says:

    Shay,
    Is it available in 2.0 M3 or 2.1.0 M3? I think it is a very important feature. Especially if you use OSEM it affects performance very seriously.

  2. Shay Banon Says:

    My typo, it is in upcoming 2.1 M3. I will fix the blog entry.

  3. Brooks Lyrette Says:

    Will this also be available from XML?

  4. Shay Banon Says:

    Sure. The reference element has a lazy attribute as well.

  5. Brooks Lyrette Says:

    Hey Shay,

    I see that GA has come out. I can not find anything about using lazy in XML.

    Can you point me in the right direction.

    Thx!

  6. Shay Banon Says:

    Reference element has a lazy attribute.

    p.s. I suggest asking question on the forum, it is much simpler to track.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>