Spring and EJB feature comparison.
Feature |
EJB |
Spring |
Transaction management |
- Must use a JTA transaction manager.
- Supports transactions that span remote method calls.
|
- Supports multiple transaction environments through its PlatformTransactionManagerinterface, including JTA, Hibernate, JDO, and JDBC.
- Does not natively support distributed transactions—it must be used with a JTA transaction manager.
|
Declarative transaction support |
- Can define transactions declaratively through the deployment descriptor.
- Can define transaction behavior per method or per class by using the wildcard character *.
- Cannot declaratively define rollback behavior—this must be done programmatically.
|
- Can define transactions declaratively through the Spring configuration file or through class metadata.
- Can define which methods to apply transaction behavior explicitly or by using regular expressions.
- Can declaratively define rollback behavior per method and per exception type.
|
Persistence |
Supports programmatic bean-managed persistence and declarative container managed persistence. |
Provides a framework for integrating with several persistence technologies, including JDBC, Hibernate, JDO, and iBATIS. |
Declarativesecurity |
- Supports declarative security through users and roles. The management and implementation of users and roles is container specific.
- Declarative security is configured in the deployment descriptor.
|
- No security implementation out-of-the box.
- Acegi, an open source security framework built on top of Spring, provides declarative security through the Spring configuration file or class metadata.
|
Distributed computing |
Provides container-managed remote method calls. |
Provides proxying for remote calls via RMI, JAX-RPC, and web services. |
Recent Comments