mysema/querydsl — Issue #49: @QueryInit seems broken in QueryDSL 2.2.3 
Author: mglauche
Created: 2011-11-18 10:51:59+00:00
State: open

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 entityList;

Map 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 ?