Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6781347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:36:49+00:00 2026-05-26T16:36:49+00:00

I am trying to create a Java EE Web Application with JSF 2, Spring

  • 0

I am trying to create a Java EE Web Application with JSF 2, Spring and Hibernate. I’m fairly new to this stack, so I need some help on best practices in organizing an application.

My initial objective is simple, a User logins in, and her session is not closed until she logs out. Here is what I have come up with so far:

  • User entity class, annotated with @Entity so that it is persisted. Not registered as a JSF or managed bean. Simple POJO with private fields (name, surname etc) and with accessors.

  • An interface for a DAO to interact with the User class: getUserById(), saveUser() etc.

  • An implementation of the DAO. Marked with Spring’s @Repository and with Hibernate’s SessionFactory @Autowired and added in ApplicationContext via component-scan.

Now, for a user browsing the site, I believe I should not create a session-scoped bean from my User class, is that correct? I think the best practice would be to never directly touch the User class, only through DAO.

So, do I need to have another bean UserManaged (probably ManagedBean and session scoped) that duplicates the fields of the User class; and use that in my JSF files? So, the beans user that are created when user interacts with the website should be handled by JSF, and the rest by Spring? But wouldn’t that duplication break the DRY principle, having the same fields as in User in another UserManaged class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:36:49+00:00Added an answer on May 26, 2026 at 4:36 pm

    I’ve always preferred to use different objects for Hibernate/JPA entities and JSF beans, decoupling the differents tiers and having different context for the objects. It avoids also attach/detach problems with ORMs, and let me have a decoupled Service Oriented Arquitecture.

    However, if I’d really want to do that with JSF and Hibernate, I’d avoid annotations in the beans:

    • Using Hibernate without annotations, keeping the mapping information
      in a mapping xml file.
    • Using JSF 2 with a xml file with all information about JSF beans.

    So, I hadn’t in the classes neither any persistence information nor any JSF information, and I could use the same objects for both tiers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a web user interface for a Java application. The user
I'm trying to create an excel spreadsheat in my seam java application. This is
I'm trying to create a simple Java app that uses JNI to call some
I am trying to create my first GUI application using (Java + Eclipse +
I am trying to create a Debian package for a Java application. In my
I am trying to create a web application using the MVC design pattern. For
Hi so I am trying to create a deb package for a web application
I'm trying to implement spring-security to handle authentication and authorization of my web application.
I'm trying to deploy some web services in a WAR application on JBoss 5.1.0.
I'm trying to create a web application which will get input from system. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.