@QueryInit seems broken in QueryDSL 2.2.3 #49

Closed
mglauche opened this Issue Nov 18, 2011 · 4 comments

Comments

Projects
None yet
2 participants
@mglauche

Hi,
i got quite a bit problem doing deep searches with querydsl, i.e. something like :

QCustomer.address.city.zipcode.eq("1234");

I always get NPE, because city.zipcode is null.

From what i read about the QueryInit annotation i could specify the paths i'm querying, but this does not seem to solve my problem.
I did try:

  • "city.zipcode" in Customer
  • "*" in Customer
  • "*" along all the chain

All seem not to work, the zipcode field is always null.

From some old Bugreport i saw a small example which does show the same result:

package com.retail_sc.fabrica.querydsl;

import java.util.List;
import java.util.Map;

import com.mysema.query.annotations.QueryEntity;
import com.mysema.query.annotations.QueryInit;

@QueryEntity
@javax.persistence.Entity
public class Entity{

    @QueryInit("*")
    Entity prop1;

    @QueryInit("*")
    Entity prop2;

    List<Entity> entityList;

    Map<String,Entity> entityMap;
}
package com.retail_sc.fabrica.querydsl;

import static org.junit.Assert.assertEquals;

import org.junit.Test;


public class QuerydslConfigTest {

    @Test
    public void test(){
        assertEquals("entity.prop1.prop2.prop1", QEntity.entity.prop1.prop2.prop1.toString());
    }

}

here the NPE will come along the path.

Interestingly, the @QuerydslConfig annotation used before (and which is still documented in http://www.querydsl.com/static/querydsl/2.2.3/reference/html/ch03s02.html) does not seem to exist anymore.

How and where to specify the correct query path ?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 19, 2011

Member

We renamed @QuerydslConfig to @config. I will update the docs. Sorry about that.

I just added support for deep wildcard initializations. It should now work like this :

@QueryEntity
public class Entity{

    @QueryInit("*.*")
    Entity prop1;

    @QueryInit("*")
    Entity prop2;

    List<Entity> entityList;

    Map<String,Entity> entityMap;
}

I will make a release tomorrow.

Member

timowest commented Nov 19, 2011

We renamed @QuerydslConfig to @config. I will update the docs. Sorry about that.

I just added support for deep wildcard initializations. It should now work like this :

@QueryEntity
public class Entity{

    @QueryInit("*.*")
    Entity prop1;

    @QueryInit("*")
    Entity prop2;

    List<Entity> entityList;

    Map<String,Entity> entityMap;
}

I will make a release tomorrow.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 19, 2011

Member

Released in 2.2.5

Member

timowest commented Nov 19, 2011

Released in 2.2.5

@timowest timowest closed this Nov 19, 2011

@mglauche

This comment has been minimized.

Show comment
Hide comment
@mglauche

mglauche Nov 20, 2011

Thanks for the quick patch !

Would
@QueryInit("prop2.prop1.prop2.prop1")

also work ? or

@QueryInit("prop2.prop1.*") ?

Thanks for the quick patch !

Would
@QueryInit("prop2.prop1.prop2.prop1")

also work ? or

@QueryInit("prop2.prop1.*") ?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 20, 2011

Member

Maybe just prop2.prop1

Member

timowest commented Nov 20, 2011

Maybe just prop2.prop1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment