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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:56:58+00:00 2026-05-26T07:56:58+00:00

I am making a Java EE application just to use what I learn while

  • 0

I am making a Java EE application just to use what I learn while reading in the books. I made a simple Entity and a DAO object that do different actions on this Entity such as create, update etc. Then in my EJB I want to use this DAO object so that I later can expose it to JSF etc.

I am having a little problems of understanding how to use objects of different classes in different layers of my application. How do I expose them to each other?

Do I just do as in regular Java SE? Have properties for the different classes and instantiate them in the classes I want? (No probably not, I have seen the use of @Inject and so on, but I do not understand one bit of it. And not when I can use it either)

I would apprciate some text on when/how we use the different annotations and how we connect different layers rather than just some code showing it.

I am on the Java chat if anyone have some spare time =)

  • 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-26T07:56:58+00:00Added an answer on May 26, 2026 at 7:56 am

    You’re asking too general questions. Grab some decent book on Java EE (there are tons of them). For better understanding of dependency injection, I’d recommend official Weld documentation. However here is a typical example aimed to show you how to connect different Java EE layers:

    JPA Entity:

    @Entity
    public class Employee {
    
      @Id
      private Long id;
    
      private String name;
    
      //getters and setters
    }
    

    EJB bean:

    @Stateless
    public class EmployeeService {
    
      //The entity manager will be injected automatically  
      @PersistenceContext
      private EntityManager em;
    
      public Employee findEmployeeById(Long id) {
        return em.find(Employee.class, id);
      }
    
    }
    

    JSF controller (let’s assume it’s CDI-bean):

    @Named
    @SessionScoped
    public class EmployeeController implements Serializable {
    
      //using CDI @Inject annotation empService will be initialized automatically
      @Inject
      private EmployeeService empService;
    
      //this method can be called from .xhtml page
      public String obtainEmployeeName(Long id) {
        String empName = "";
        Employee emp = empService.findEmployeeById(id);
        if (emp != null) {
          empName = emp.getName();
        }
        return empName;
      }
    }
    

    xhtml page:

    <h:outputText value="#{employeeController.obtainEmployeeName(3)}" />
    

    Update
    Some books that might help:

  2. Pro JPA 2: Mastering the Java Persistence API
  3. Core JavaServer Faces (3rd Edition)
  4. Beginning Java EE 6 with GlassFish 3
  5. These are quite popular and cover a lot of ground.

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

Sidebar

Related Questions

EDITED: Java httpPost into .asp form I am making an application that will display
I am making a java desktop application for billing customers that will be using
I'm making an application with java that has a JTextPane. I want to be
I'm making a Java application with an application-logic-thread and a database-access-thread. Both of them
I'm making a shopping list mobile application (Java ME) and i have two classes;
I am making an application with Java Swing and i have a problem. I
Using J2SE, I tried making a LAN application using java.net.*, and it worked perfectly.
Im am making an Java SWT program that is required to run on both
I'm trying to create an application that can use the android as a fax
Everyone who's done any web application development in Scala knows that you can use

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.