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

@QueryInit seems broken in QueryDSL 2.2.3 #49

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

@QueryInit seems broken in QueryDSL 2.2.3 #49

mglauche opened this issue Nov 18, 2011 · 4 comments

Comments

@mglauche
Copy link

@mglauche mglauche commented Nov 18, 2011

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
Copy link
Member

@timowest 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
Copy link
Member

@timowest timowest commented Nov 19, 2011

Released in 2.2.5

@timowest timowest closed this Nov 19, 2011
@mglauche
Copy link
Author

@mglauche mglauche commented Nov 20, 2011

Thanks for the quick patch !

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

also work ? or

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

@timowest
Copy link
Member

@timowest 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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants