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

  • SEARCH
  • Home
  • 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 6841663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:59:40+00:00 2026-05-26T23:59:40+00:00

As I am new to all this Java EE ocean, there is so much

  • 0

As I am new to all this Java EE ocean, there is so much I want to know, and as I read more and more info on the internet I get more confused than anything gets clear. Are my presumptions right:

  1. Firstly we need Entity class (POJO) with @Entity, @Table, @Column and etc. annotations.
  2. Secondly we make Service class which will make physical changes in single database’s table using SessionFactory which will be @Autowired. If I’m correct is this so called DAO? And do this class need to implement any other class? Because I saw numerous examples where connection between controller and entity ares like 3 classes long (one of which is interface). And there are some implementations in those classes.
  3. The last thing we need is controller which will have Service class object which will also be @Autowired.

So to summarize: we have @Controller class which uses @Autowired service class object. Service class object consists of save/delete/select methods that are executed through @Autowired SessionFactory object?

If I’m right what configurations are needed for all this scheme to work? And if I’m wrong please explain how this must be done with as little configuration in XML files as possible.

Thank you.

  • 1 1 Answer
  • 1 View
  • 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-26T23:59:41+00:00Added an answer on May 26, 2026 at 11:59 pm

    There are several questions buried in here, so I will try and give you high level answers.

    @Entity
    This will define your objects, and more importantly (with other annotations you mention) it will allow Hibernate/JPA to successfully map and persist that data to the RDBMS of choice.

    The other information you need to make this work (besides of course including the appropriate libraries) is the hibernate configuration file (hibernate.cfg.xml) which will be used to determine the database connection info, other hibernate settings, and classes to be scanned (assuming annotations are in use).

    @Service
    Is a spring stereotype that indicates that Spring should manage this class and that it should be considered a service (i would consider this an almost marker interface, I believe it is handled almost the same way as @Component). As far as implementing any interface or extending specific classes, I don’t believe so. I believe the big issue is getting hold of the entity manager. Let me pull a short snippet from a hobby project…

    @Service
    public class UserServiceImpl implements UserService {
    
    
    private SessionFactory sessionFactory;
    
    public UserServiceImpl() {
        sessionFactory = new Configuration().configure().buildSessionFactory();
    
    }
    
    
    @Override
    public Collection<Person> getAllUsers() {
        Collection<Person> peoples = new ArrayList<Person>();
        Session session = sessionFactory.getCurrentSession();
        session.beginTransaction();
        Query query = session.createQuery("from Person").setMaxResults(500);
        peoples.addAll(query.list());
        session.close();
        return peoples;
    }
    }
    

    @Autowired
    Autowired is an annotation Spring uses to indicate that the field annotated will be injected (by type is probably the most common, though certainly not the only way) by spring (as long as the class is managed by spring or marked as @Configurable).

    To counter-summarize:
    the only XML you’ll need is the hibernate config file. You don’t (necessarily have to even autowire the session factory as long as you have access to it.

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

Sidebar

Related Questions

First of all, I'm fairly new to Java, so sorry if this question is
I am new to all this, but here goes: There is an apple file
This might be a stupid question but I'm new at all this. I want
I'm pretty new to Java and this has me really confused. I have two
New to all this so forgive my ignorance. I am trying to figure out
I am very new at all this c# Windows Phone programming, so this is
I'm getting this error message on all projects (including brand new empty templates) I'm
This Code: Something = new Guid() is returning: 00000000-0000-0000-0000-000000000000 all the time and I
I have this block of code: users = Array.new users << User.find(:all, :conditions =>
The topic generically says it all. Basically in a situation like this: boost::scoped_array<int> p(new

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.