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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:25:58+00:00 2026-05-16T18:25:58+00:00

Obviously using stateless EJB beans in an entity bean smells, but please consider a

  • 0

Obviously using stateless EJB beans in an entity bean smells, but please consider a scenario as follows and tell me if you know of a better solution:

  1. I have an InvoiceTemplate Entity Bean with field NextInvoiceDate
  2. Generating NextInvoiceDate is a complex procedure and should be performed outside of the InvoiceTemplate class
  3. NextInvoiceDate should be updated each time InvoiceTemplate is stored to the db

For now I have logic regarding the generation of NextInvoiceDate in @PrePersist @PreUpdate methon in InvoiceTemplate entity bean. The logic is getting more and more complicated and I want to move it outside of the InvoiceTemplate entity bean. It looks to me that there should be a service to calculate NextInvoiceDate. But then is it right to invoke this service from the inside of InvoiceTemplate?

  • 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-16T18:25:58+00:00Added an answer on May 16, 2026 at 6:25 pm

    It isn’t such a smell – it is a lean towards domain-driven design.

    I don’t know of any way to do this automatically, but you can:

    • in the session beans where you handle your Invoicetemplate, inject the helper bean that has the logic to calculate the next date
    • create a private field with a setter on the entity, and before you start using it call entity.setNextDateHelper(..)

    You can also check whether AspectJ doesn’t offer some EJB options so that you can inject the EJB whenever an entity of a given type (InvoiceTemplate) is created. AspectJ works like that with spring beans, I don’t know whether there are such options for EJB.

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

Sidebar

Related Questions

Please help. I am obviously no expert but using suggestions from this site, I
I'm using the Django manage.py runserver for developing my application (obviously), but it takes
I'm using memcache for caching (obviously) which is great. But I'm also using it
I am using a custom class based off RelativeLayout but it obviously doesn't render
hi guys i have this script but obviously im not using foreach right i
I have to allocate a struct from within another function, obviously using pointers. I've
I am using WCF RIA services with silverlight. Obviously I am using this primarily
Obviously the point of using named constants over magic numbers is for code clarity
I'm using a streaming distribution on CloudFront to serve media via RTMP. Obviously I
I am using http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/portal/portal.html to build a portal. Obviously, i have custom windows inside

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.