i have an fully application build with javafx and hibernate and my problem is The manage of transactions ,i found the solution by using spring framework i search in google a way to integrate javafx and spring i found a hard way there is a simple way?
Asked
Active
Viewed 143 times
-1
-
Including spring in your application just to use hibernate is like buying Bolivia because you need a lithium battery. – Federico klez Culloca Aug 19 '20 at 10:13
-
Spring `@Transactional` does a lot of stuff for you but Hibernate can handle transactions itself if that's all you need: see "Non-managed environment" https://docs.jboss.org/hibernate/orm/3.3/reference/en/html/transactions.html – drekbour Aug 19 '20 at 10:23
-
I need Spring @Transactional and CrudRepository iterface to organise my code . – Benzellat Djamel Eddine Aug 19 '20 at 11:03
-
As commented above, you don't *need* Spring to use Hibernate transactions, though I agree that it's easier to use spring's declarative transactional style, than programmatically defining them. And there are other benefits to using Spring (or another DI framework) in a larger JavaFX application, as it makes it much easier, for example, to inject model instances into your controllers etc. See https://stackoverflow.com/questions/48290589/javafx-spring-boot-npe (and several others) for implementations. – James_D Aug 19 '20 at 16:28
1 Answers
1
Yes, there is a simple way to integrate JavaFX in Spring.
It works just great with FxWeaver:
https://rgielen.net/posts/2019/creating-a-spring-boot-javafx-application-with-fxweaver/
by René

alex87
- 449
- 3
- 8
-
I’ve never quite understood the benefit of FXWeaver - it’s reasonably straightforward to combine the two frameworks manually. Also note the documentation you linked has controller classes scoped as singletons, which is *always* a mistake- JavaFX controllers should always be scoped as `prototype` if you are managing them with spring. – James_D Aug 19 '20 at 11:33