Comments on: Replace Play @Transactional with something better https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/ Development on the Java platform Sun, 29 Dec 2013 15:32:01 +0000 hourly 1 https://wordpress.org/?v=6.3.3 By: Jens https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4218 Sun, 29 Dec 2013 15:32:01 +0000 http://www.jensjaeger.com/?p=1780#comment-4218 Hey JJ,

a extended version of the finder was pushed to https://github.com/jensjaeger/play4jpa. A blog post, unit test and more documentation is in progress.

Jens

]]>
By: JJ https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4156 Wed, 18 Dec 2013 13:31:12 +0000 http://www.jensjaeger.com/?p=1780#comment-4156 I was able to make it work, but I needed to add a method join() to your model.

See it there : https://gist.github.com/miclefebvre/16b26137d886652e65d8

It’s not as nice as in Ebean but it does the job
If we have 4 tables it will look like

find.where()
.join(“tableA”, “tableA”)
.join(“tableA.tableB”, “tableB”)
.join(“tableB.tableC”, “tableC”)
.eq(“tableC.value”, value)

It would have been nice and easy to have the Finder create the join automatically if it detect if the field in eq (for example) as multiple dot (.) tableA.tableB.tableC but it wont work if we add other restriction like:

.or(Restrictions.isNull(“tableA.Table.date”),
Restrictions.lt(“tableA.Table.date”, now))

Let me know if you have other idea.

]]>
By: JJ https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4152 Tue, 17 Dec 2013 20:23:47 +0000 http://www.jensjaeger.com/?p=1780#comment-4152 I decided to use your gist for JPA finder and it work great.

The only thing I couldn’t get to work is with @ManyToOne

If I have en entity with 2 variables

@Id @GeneratedValue(strategy=GenerationType.AUTO)
public Long id;
@ManyToOne(fetch=FetchType.EAGER)
public OtherModel ortherModel;

.eq(“otherModel.code”, “value”)

It shows a could not resolve property otherModel.code
Maybe there’s something I don’t know in jpa. Because in JPQL it would work but I don’t know Criteria api.

Do you have an idea ?

]]>
By: Jens https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4083 Sun, 08 Dec 2013 14:16:48 +0000 http://www.jensjaeger.com/?p=1780#comment-4083 Hey JJ,

there is no more JPA related magic in play 2, like you know from play 1.

Jens

]]>
By: JJ https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4075 Fri, 06 Dec 2013 18:18:04 +0000 http://www.jensjaeger.com/?p=1780#comment-4075 Yess, I know it’ll be compatible with the JPA annotation. It’s just, it won’t come with all the play magic, or I’ll have to recode some part of the app.

]]>
By: Jens https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4069 Thu, 05 Dec 2013 21:37:34 +0000 http://www.jensjaeger.com/?p=1780#comment-4069 Hey JJ,

thanks for your comments.

If you use Hibernate you will be compatible with any 2.x Version of Play. In 2.3 JPA will be the default in favor of ebean. If you use the @Tx Annotation instead of the default play @Transactional you still compatible, but don’t use the withTransaction Part of Play Framework you use a custom one with another (i think better) behavior.

After some research I decided that for me hibernate is a better foundation for a new project than ebean. Other think the same. There is a reason that eBean will be replaced with JPA in Play 2.3.

The @Tx implementation in this post is extracted from a big client project im working on at the moment. In the future I will write some more about our hibernate jpa implementations here.

Jens

]]>
By: JJ https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4068 Thu, 05 Dec 2013 16:57:35 +0000 http://www.jensjaeger.com/?p=1780#comment-4068 This implementation is only a snippet and not in your project yet ?

]]>
By: JJ https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4066 Thu, 05 Dec 2013 16:46:38 +0000 http://www.jensjaeger.com/?p=1780#comment-4066 Yeah, really good work.

I just don’t know if I should go with EBean, JPA or your version of JPA. Because with the next update of play, it’s sure that my code will be incompatible with the new api(if I use any) unless they use your project as a base.

But Ebean will still be supported as a plugin.

It’s difficult to choose because it will be used in a really critical component of our system.

]]>
By: Jens https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4051 Mon, 02 Dec 2013 20:31:12 +0000 http://www.jensjaeger.com/?p=1780#comment-4051 There is already a basic implementation of a play jpa finder:

https://gist.github.com/jensjaeger/93da1c8c0bf8f627fae3

I will integrate a more advanced version of the finder in the play4jpa project soon. Hopefully I also find time to blog about it as well.

Happy coding
Jens

]]>
By: JJ https://jensjaeger.com/2013/11/replace-play-transactional-with-something-better/comment-page-1/#comment-4050 Mon, 02 Dec 2013 19:28:55 +0000 http://www.jensjaeger.com/?p=1780#comment-4050 Nice thanks for the code.

It’s sad because all the integration with ebean was already there.

We will have to write our own finder (or copy the one in play 1.0)

I’ll check your code on github to see if I integrate it in my project.

]]>