Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

How to integrate querydsl in your javaee7 project

This guide requires knowledge on:
  • maven
  • git
  • eclipse
  • querydsl
  • wild fly
We will show you how to modify the javaee7-archetype project to integrate querydsl. For those who do not know, it is a library to unify queries in java. What I like more about it is that you can fluently construct your api. For more info refer to: http://www.querydsl.com/static/querydsl/4.1.3/reference/html_single/

Follow this guide to setup your project:
http://czetsuya-tech.blogspot.com/2017/04/how-to-setup-arquillian-testing-with.html
Take note, of the arquillian configuration, as we will need it later.

Since I am lazy :-), I will just provide the test project that I have created in GitHub: https://github.com/czetsuya/JavaEE7-QueryDSL-Demo

Things you should take notice:
  • In resources I have added a JPAQueryFactoryProducer:
    @Produces
     public JPAQueryFactory produceJPQQueryFactory() {
      return new JPAQueryFactory(em);
     }
    
  • Note that I have modified Member entity, added a BaseEntity and Identifiable interface.
  • I have added a new package: com.broodcamp.javaee_querydsl_demo.repository and the classes inside it.
  • I have also modified: MemberRegistrationTest, so that we can run the arquillian test correct.
To run arquillian simply execute this command inside your project in the terminal:
>mvn clean test -Parq-wildfly-managed

The test should run without error.
How to integrate querydsl in your javaee7 project How to integrate querydsl in your javaee7 project Reviewed by Edward Legaspi on Sunday, April 16, 2017 Rating: 5

No comments:

Powered by Blogger.