can i use springsmvc + ejb + hibernate for distributed application?

240 views Asked by At

can i use the combination of springs mvc + EJB + Hibernate for my application. My application is a distributed application. So is this combination suitable for my application?


I want to develop an distributed application and have started the gui coding using springs-mvc
and now I want to access the database and I'am confused weather to use jdbc or hibernate?

I read somewhere that hibernate is not suitable for distributed applications. So can anyone please help me in deciding weather to use jdbc or hibernate?

thank you in advance.

1

There are 1 answers

2
Sergio On

TL;TR: Yes you can.

Long Version:

JDBC vs JPA (or Hibernate) : JPA/Hibernate tends to be the way to go if you need a Object Oriented version of your domain (in general it's something good). JDBC is more used for performance tasks (batch), or a simple query tools (even for legacy systems).

SpringMVC vs JSF: JSF is used when you prefer to use a component library (eg: primefaces), SpringMVC tends to be used when you want full control of your Javascript+CSS+HTML. As you already know, JSF is an abstraction that avoids dealing with web technologies as much as possible. Neither is better than the other, just different

Spring Framework vs EJB/CDI: Matter of preferences, they almost offer same as the other, the programming model is almost the same, keep in mind that some Spring characteristics are exclusive (Vendor Lock ahead!), and to some extent (my biased opinion) EJB+CDI is more elegant and simple.

Alternative solution: If you are familiar with SpringMVC, so go with it, you can even use it in a Java EE server

Warning: Don't use the old buggy way tomcat + zillions of jars, if you go with Java EE use at least TomEE, if you prefer Spring, use the tc Server.

Note: App servers right now are not heavy weight (see also: TomEE, wildfly).

EDIT:

For "distributed" systems you can use JMS or Webservices (there are other techniques but not as mainstream).

The web-services way it's simpler to achieve with EJB (@Webservice or @Path annotations), you can go with JMS but it's a little bit harder to maintain and monitor, also, maybe you will need to acknowledge some clients and you need to deal with the inherited asynchronous of JMS, go with JMS Only-when-necessary.