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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:29:35+00:00 2026-05-20T00:29:35+00:00

I am working on a project where we need to decide how we are

  • 0

I am working on a project where we need to decide how we are going to expose our persistence layer.

There are currently two options on the table:

1) Use plain DAOs. These would implement an interface and be injected (probably using Weld) in the Business Components which are EJBs. Internally they would use JPA/Hibernate for persistence.

2) Rather than injecting the DAOs using Weld, they would be implemented as EJBs, and injected with @EJB in the Business Components.

Does it really make sense to use EJBs for the persistence layer when we are not using its capabilities (e.g. transaction management – business layer deals with this)?

Is there any performance penalty in using EJB over Weld (or the other way round)?

What option would you think is best?

  • 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-20T00:29:35+00:00Added an answer on May 20, 2026 at 12:29 am

    Using EJBs for a JPA based DAO is a perfectly natural fit.

    If the transaction normally starts in your business layer (which are also EJBs as you mention) the transaction will naturally propagate to them. Should you ever want to use the DAO separately, then a transaction will be started for you. You may not use this feature now, but it comes totally free should you ever need it.

    Also, should you ever need to a single operation in its own transaction, then this is trivial when your DAOs are EJB based.

    Injecting your business EJBs with the DAO EJBs may have a potential performance advantage. As only stubs are injected that delegate to pooled instances, injection is relatively cheap. You can inject your business EJBs with many DAOs that may or may not all be necessary for every call. I’m not 100% sure CDI has this exact same capability. It of course has scoping and conversations but not really stubs to delegate to a pool.

    Should you ever need JPA’s extended persistence context, then the stateful session bean is practically made for that, otherwise the stateless session bean would be used for DAOs.

    That said, CDI is the more modern component model and the current thinking seems to be that EJB will eventually be retrofitted as a set of CDI annotations. Starting to build up a CDI codebase and knowledge now may actually be a long term strategic benefit, and thus bodes for CDI.

    So to answer your question more directly: yes it makes sense to use EJBs for the persistence layer, but neither EJB or CDI are absolutely a wrong choice here.

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

Sidebar

Related Questions

I'm currently working on a pet project and need to do C++ development on
I am currently working on a project where users need to be able to
I am working a project where I need to generate a series of classes
I'm working on a project were we need more performance. Over time we've continued
I'm working on a project where I need the following. WCF service on the
I am working on a project where I need to create a boundary around
I am working on a project where I need to deal at the byte
I've been working on a project where I need to iterate through a collection
I'm working on a project where I have 2 web services that need the
I'm working on a database project and I need to create Outlook 2007 plugin

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.