How to use atlassian-pocketknife-querydsl

I intend to access external databases with a P2 plugin and I would like to use the builtin library querydsl;

https://bitbucket.org/atlassian/atlassian-pocketknife-querydsl/

I did a few attempt but none worked, do you have some simple example about how to create a database connection and perform select and updates?

Regards

The library makes a large assumption about where the connections come from. And that is that TransactionalExecutorFactory is giving out connections

https://bitbucket.org/atlassian/atlassian-pocketknife-querydsl/src/ddaa68e513215222daeaadc63bdcea8c562b6cca/api/src/main/java/com/atlassian/pocketknife/internal/querydsl/DatabaseAccessorImpl.java?at=master&fileviewer=file-view-default

This is all wired in at runtime when your plugin Spring context is resolved.

You would have to “mock out” the TransactionalExecutorFactory to give out connections to your other database

But honestly this library is a thin wrapper over querydsl itself. In think you might get better mileage out of going direct to querydsl and provide connections to it.

3 Likes

That was what I thought! Thank you bbaker!

I’ll go ahead and use querydsl instead.

What are the main reason(s) for using pocketknife vs using QueryDSL directly, even for the local DB? Is it just the Spring wiring?