28.4. Configuring Seam without EJB
Seam is useful even if you're not yet ready to take the plunge into EJB 3.1. In this case you would use Hibernate 4 instead of EJB 3.1 persistence, and plain JavaBeans instead of session beans. You'll miss out on some of the nice features of session beans but it will be very easy to migrate to EJB 3.1 when you're ready and, in the meantime, you'll be able to take advantage of Seam's unique declarative state management architecture.

Seam JavaBean components do not provide declarative transaction demarcation like session beans do. You could manage your transactions manually using the JTA
UserTransaction or declaratively using Seam's @Transactional annotation. But most applications will just use Seam managed transactions when using Hibernate with JavaBeans.
The Seam distribution includes a version of the booking example application that uses Hibernate and JavaBeans instead of EJB, and another version that uses JPA and JavaBeans. These example applications are ready to deploy into any Java EE application server.
28.4.1. Boostrapping Hibernate in Seam
Seam will bootstrap a Hibernate
SessionFactory from your hibernate.cfg.xml file if you install a built-in component:
<persistence:hibernate-session-factory name="hibernateSessionFactory"/>
You will also need to configure a managed session if you want a Seam managed Hibernate
Session to be available via injection.
<persistence:managed-hibernate-session name="hibernateSession" session-factory="#{hibernateSessionFactory}"/>
28.4.2. Boostrapping JPA in Seam
Seam will bootstrap a JPA
EntityManagerFactory from your persistence.xml file if you install this built-in component:
<persistence:entity-manager-factory name="entityManagerFactory"/>
You will also need to configure a managed persistence context if you want a Seam managed JPA
EntityManager to be available via injection.
<persistence:managed-persistence-context name="entityManager" entity-manager-factory="#{entityManagerFactory}"/>
28.4.3. Packaging
We can package our application as a WAR, in the following structure:
my-application.war/
META-INF/
MANIFEST.MF
jboss-deployment-structure.xml
WEB-INF/
web.xml
components.xml
faces-config.xml
lib/
jboss-seam.jar
jboss-seam-ui.jar
jboss-el.jar
hibernate-core.jar
hibernate-annotations.jar
hibernate-validator.jar
...
my-application.jar/
META-INF/
MANIFEST.MF
seam.properties
hibernate.cfg.xml
org/
jboss/
myapplication/
User.class
Login.class
Register.class
...
login.jsp
register.jsp
...
If we want to deploy Hibernate in a non-EE environment like Tomcat or TestNG, we need to do a little bit more work.