0
votes

I'm writing a JavaFX Application which previously use Spring/QueryDSL for DI and persistence.

I'm hoping to move to using either Dagger or Guice (instead of spring) and Hibernate ORM.

I have noticed that Spring offers some nice functionality on top of hibernate, such as transaction management via @Transactional.

Are there other means of avoiding "boilerplate code" such as opening sessions, beginning transactions, committing transactions and closing sessions via some sort of hibernate configuration? Or are these features I'm really only going to get if I use Spring?

1
I'm no expert at this, but hibernate also provides annotations to avoid a lot of boilerplate code. Refer: docs.jboss.org/hibernate/annotations/3.5/reference/en/… - Anurag Kapur
EJB 3 has also the same functionality :) Such a features can only be provided by frameworks that offer AOP. As I see Guice (I am not an expert of this one) also offers AOP so you can always write a simple version of it by your own :) - Marek Raki

1 Answers

1
votes

Guice has @Transactional support for JPA providers such as Hibernate using guice-persist, Dagger does not mention support for this.

If you are using Hibernate as your JPA provider, using Spring with @Transactional would probably be the most natural fit for building your backend. You would find a loss less documentation, examples, blog posts, books and online help in general using other alternatives than with Spring/Hibernate.