QueryDSL 和 Play 框架 [英] QueryDSL and Play Framework

查看:20
本文介绍了QueryDSL 和 Play 框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 QueryDSL 和 JPA2 有一段时间了,这是我所知道的最强大的 ORM 组合.JPA Criteria API 是一场灾难.使用 QueryDSL 我也忘记了 JPQL.

I'm using QueryDSL with JPA2 for some time, and it's the most powerful combination for ORM I know. JPA Criteria API is a disaster. With QueryDSL I've forgotten about JPQL too.

我想在 Play 中使用 QueryDSL!除了 JPQL 的内联部分作为字符串外,一切在 Play 中看起来都很好.这让我想起了 CakePHP...

I'd like to use QueryDSL with Play! Everything looks very good in Play except those inline parts of JPQL as strings. It reminds me of CakePHP...

我想在 Play 中使用可重构的查询语言(以及其他一些东西:)).

I'd like to have refactoring-proof querying language in Play (and some other things :) ).

QueryDSL 的使用很简单.它只需要 EntityManager.但是 QueryDSL 有这个 APT 类生成器(就像 Hibernate 中用于 citeria API 的那个).

QueryDSL usage would be straightforward. It needs EntityManager only. But QueryDSL has this APT class generator (just like the one from Hibernate for citeria API).

有没有人设法让这个类生成器与 Play 一起工作?是否可以重新创建和热重新加载这些类?

Does anyone managed to get this class generator work with Play? Is it possible to recreate and hot reload those classes?

推荐答案

我认为 Project Lombok 的 nofollow">经验 在 Play 框架中进行注释处理会对您有所帮助.设置 APT 处理很容易,但非常具体.查看 play-lombok 模块.不要忽略 commands.py 文件并更改 org.eclipse.jdt.core-3.6.0.jar 引用以匹配您的 Play 版本中使用的版本.

I think the experience of Project Lombok with annotation processing in the Play framework will be helpful to you. It is easy to setup APT processing, but very specific. Look at the play-lombok module. Don't ignore the commands.py file and change the org.eclipse.jdt.core-3.6.0.jar reference to match the version used in your version of Play.

我在 Play 框架中为我最近的所有项目使用 Querydsl.但是,我不使用 JPA.我将自己的对象模型与 Querydsl 一起使用,而不是 ORM,以根据情况获得良好的拟合.我不需要使用 Querydsl 的 APT.

I use Querydsl in the Play framework for all my recent projects. I do not use JPA, however. I use my own object models with Querydsl instead of ORM to get a good fit depending on the situation. I haven't had a need for APT with Querydsl.

我没有在 Play 和 Querydsl 之间创建任何紧密的集成,但我只是在每个控制器方法中使用了一些样板.总有一天我会写一个合适的插件.

I have not created any tight integration between Play and Querydsl, but I just use a bit of boilerplate in each controller method. Some day I'll write a proper plugin.

这篇关于QueryDSL 和 Play 框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆