How to work with databases for sites written in Java, or rather Wicket?

I am new to website development using Java, but I started with Wicket and made a small website. I would like to expand what I have already done (a site with a form, shortcuts and links) and implement a database connection.

I looked at a few examples, for example, Mystic Paste, and I see that they use Hibernate and Spring. I've never touched Hibernate or Spring before, and frankly, the intense use of annotations scares me a bit, as I still haven't used them before, except for suppressing warnings and overriding.

At this point, I have one Connection object that I installed in the WebApplication class during initialization. Then I retrieve this connection object whenever I need to execute queries. I don't know if this is bad for a working web application or not.

All help is appreciated.

+3
source share
3 answers

Wicket, Spring, and Hibernate are pretty much the standard stack for Wicket applications. Or suppose any web infrastructure, Spring and Hibernate, is pretty much the standard stack for any web infrastructure.

Wicket, @SpringBean - . , OpenSessionInViewFilter Hibernate ( Hibernate ).

Spring Hibernate - , , ( XML).

Spring Hibernate, OpenSessionInViewFilter - : , , . , , . beans ;)

+3

, Connection , - .

, .

.

+2

If you have time, you can dig Apache Cayenne , it is much lighter than Hibernate, and for injection of dependencies it is combined with Google Guice , again very easy. Wicket has a wicket-guice subproject that provides DI in wicket components, like Spring Context. IMHO this is a fair alternative, it works very well so far.

+2
source

Source: https://habr.com/ru/post/1740172/


All Articles