Dynamic Query Builder - Replace EntityBasePath instace while keeping the end number path

41 views
Skip to first unread message

MIke

unread,
Apr 15, 2015, 3:41:26 PM4/15/15
to quer...@googlegroups.com
Hello guys,

first of I would like to say querydsl is amazing in our project and provided a lot of rapid development aspects we really needed for our dev cycle.

I just run lately into a possible wall, I would like to ask you if there is anything to be done, before i revert to a full dynamic PathBuilder implementation.

I have created some enums which hold detail of general criteria.

in the enums I have a SimpleExpression "Field" which I use  it to designate the required EntityBasePath with its ending number or string path (according to the ORM applied)

e.g QContext.context.authority.id

Now everything works find when I do query.where("field".eq("value"));

But in one particular secondary join (is a second join of the SAME QContext.context to itself kinda) which I add in the major source from clause as :

 QContext secondContext = new QContext("secondContext");
 query....addJoin(JoinType.DEFAULT,secondContext ).where...joinclause

The dynamic loop appends the previous "field" SimpleExpression to the primary QContext one and not the secondary.

I am trying so hard to replace the EntityBasePath while keeping the formatting I had in the enum as I want to utilize the dynamic join capabilities, but with no avail....

Is there any way to replace the default instantiated QContext.context with the QContext I manually have added in the secondary join?


Thanks for everything even if I dont get a reply. Your work is inspiring.

MIke

unread,
Apr 16, 2015, 11:36:07 AM4/16/15
to quer...@googlegroups.com
I made it work by changing the intantiation like new QContext("xxx_context") matching the alias given by the dynamic generator!

No need to reply thanks again for the amazing framework!

timowest

unread,
Apr 16, 2015, 1:20:40 PM4/16/15
to quer...@googlegroups.com
Hi Mike.

Good you got it figured out. You need indeed to make sure that the property paths you use in Querydsl match their parent variables.

Timo
Reply all
Reply to author
Forward
0 new messages