[infinispan-dev] EntityLoader as interface?

Sanne Grinovero sanne at infinispan.org
Thu Sep 13 11:35:43 EDT 2012


On 13 September 2012 17:24, Ales Justin <ales.justin at gmail.com> wrote:
> While thinking about EntityLoader as interface (imo, it should be an interface ...),

+1, feel free to patch it, but before jumping on it make sure you need
to replace it; I'm not sure of that.

> just stumbled upon this:
>
>    public List<Object> load(EntityInfo... entityInfos) {
>       int size = entityInfos.length;
>       ArrayList<Object> list = new ArrayList<Object>(size);
>       for (EntityInfo e : entityInfos) {
>           Object entity = load(e);
>           if (entity != null) {
>               list.add(entity);
>           }
>       }
>       return list;
>    }
>
>
> We pass "size" into ArrayList.
> What if some "entity" is the null, hence not added, will the "list" size still be ok?
> I would say you need to call "trimToSize"?

No that's not needed.

>
> @Sanne: how would we get just key to be used / loaded, not full entity;
> e.g GAE has Query::setKeysOnly
> ... you mentioned some projections

I was referring to the following Hibernate Search capability:
http://docs.jboss.org/hibernate/search/4.2/reference/en-US/html_single/#projections

In short:

org.hibernate.search.FullTextQuery query =
    s.createFullTextQuery( luceneQuery, Book.class );
query.setProjection( "id" );
List results = query.list();

But I just realized Infinispan Query doesn't implement _setProjection_ :-(
Open a feature request?
I'd prefer we implement projections over converting the EntityLoader
to an interface.

Sanne

>
> -Ales
>
>
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev


More information about the infinispan-dev mailing list