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 509671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:02:05+00:00 2026-05-13T07:02:05+00:00

till now i still worked with JSF and JPA without DAOs. Now i’d like

  • 0

till now i still worked with JSF and JPA without DAOs. Now i’d like to use DAOs. But how can i initialize the EntityManager in the DAO-Classes?

public class AdresseHome {

    @PersistenceContext
    private EntityManager entityManager;

    public void persist(Adresse transientInstance) {
        log.debug("persisting Adresse instance");
        try {
            entityManager.persist(transientInstance);
            log.debug("persist successful");
        } catch (RuntimeException re) {
            log.error("persist failed", re);
            throw re;
        }
    }
}

Have I to use Spring or is there a solution that works without Spring?

Thanks.

  • 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-13T07:02:05+00:00Added an answer on May 13, 2026 at 7:02 am

    If your container doesn’t inject the EntityManager for you, you can get one with:

    EntityManagerFactory factory;
    factory = Persistence.createEntityManagerFactory("jpatest");
    EntityManager em = factory.createEntityManager();
    

    Where “jpatest” from the unit defined in your persistence.xml

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

Sidebar

Related Questions

i have uploaded an app yesterday by 6pm but till now i can't find
I've been researching for days on the issude but till now I still haven
I've developed some web-based applications till now using PHP, Python and Java. But some
Code: $testing=sniper this and sniper that; $connectors=array('and', 'now', 'but', 'still', 'so', 'only', 'therefore', 'moreover',
I still have some confusion about this thing. What I have found till now
I have been using Micah Carrick's PAYPAL IPN class till now for web_accept but
Till now, for clear understanding I was thinking this always refers to owner of
till now i was using drawable to populate marker on my map .Now i
Up till now I have searched for hours on end and have not found
I have till now mainly concentrated on web programming thus far and now want

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.