Ratpac and persistence reference

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Ratpac and persistence reference

Endre Karlson
Is there a reference implementation of doing Hibernate with Ratpack or similar?
rus
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

rus
I haven't seen anything with Hibernate but there's this example which uses Groovy SQL https://github.com/ratpack/example-books
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

dimzava
In reply to this post by Endre Karlson
rus
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

rus
When looking at any of those 4 examples be aware that they all block the main thread. You either need to use an async driver or use the background DSL.
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

Endre Karlson
What drivers are async ?
rus
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

rus
There's http://www.allanbank.com/mongodb-async-driver/index.html for mongo. I've seen some for Postgres and MySQL with a quick google but be careful as not all drivers advertised as async are really truly async. As I understand it async wrappers over jdbc are not async, you might as well just use the background DSL.
rus
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

rus
There's also http://reactivemongo.org/ and https://github.com/bwmcadams/hammersmith for mongo which are both built on top of netty.
rus
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

rus
The last 2 are both scala though
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

Endre Karlson
Atm I'm going for Hibernate though. Wonder why there's no "threadpool" helper for ratpack atm though :(
rus
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

rus

If you're set on using hibernate then that uses jdbc, which is blocking, so your only option is to use the background dsl when doing the blocking work http://www.ratpack.io/manual/current/backgrounding.html#backgrounding

Why do you need a theadpool helper?

On 22 Dec 2013 19:37, "Endre Karlson [via Ratpack Forum]" <[hidden email]> wrote:
Atm I'm going for Hibernate though. Wonder why there's no "threadpool" helper for ratpack atm though :(


If you reply to this email, your message will be added to the discussion below:
http://forum.ratpack.io/Ratpac-and-persistence-reference-tp282p290.html
To start a new topic under Ratpack Forum, email [hidden email]
To unsubscribe from Ratpack Forum, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

Endre Karlson
As far as I see that's what Play 2.x uses and it also has netty.
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

Luke Daley
Administrator
In reply to this post by Endre Karlson
What exactly do you mean here?
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

Endre Karlson
I am looking to a reference basically of Hibernate. As far as I know they all block when doing calls ?

Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

Luke Daley
Administrator
They do. If you want to use Hibernate (or JDBC for that matter) you have two options:

1. Use the Background API to do all blocking work in the background (see: http://www.ratpack.io/manual/current/backgrounding.html#backgrounding)
2. Use Ratpack in blocking mode (i.e. ramp up the number of “main threads”)

#1 gives better performance, while #2 gives you an easier programming model.
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

sarmbruster
Slightly off topic but related to "persistence and ratpack". I've did some experiments using Neo4j with ratpack, see my blog post at http://blog.armbruster-it.de/2013/09/some-experiments-with-ratpack-and-neo4j/.



2013/12/23 Luke Daley [via Ratpack Forum] <[hidden email]>
They do. If you want to use Hibernate (or JDBC for that matter) you have two options:

1. Use the Background API to do all blocking work in the background (see: http://www.ratpack.io/manual/current/backgrounding.html#backgrounding)
2. Use Ratpack in blocking mode (i.e. ramp up the number of “main threads”)

#1 gives better performance, while #2 gives you an easier programming model.


If you reply to this email, your message will be added to the discussion below:
http://forum.ratpack.io/Ratpac-and-persistence-reference-tp282p295.html
To start a new topic under Ratpack Forum, email [hidden email]
To unsubscribe from Ratpack Forum, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

Luke Daley
Administrator
Awesome Stefan. I had forgotten about that post.

I sent you a pull request updating the app to the latest API, which I see you merged. Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

jeff-blaisdell
In reply to this post by Endre Karlson
Its been awhile since this post was active, but I was also looking for the same thing..
Based on various sources I put together this GitHub project which integrates Hibernate, Guice, and Rat Pack.

Code review comments welcome!
https://github.com/jeff-blaisdell/kaleido-io

Hopefully it helps someone else.

rus
Reply | Threaded
Open this post in threaded view
|

Re: Ratpac and persistence reference

rus
Looks good. Thanks for sharing.

One comment would be to do as little as possible in the blocking parts. So move the criteria building outside the block and only do the IO inside.