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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:45:36+00:00 2026-06-14T15:45:36+00:00

I am learning Entity Bean and I get this error when I am doing

  • 0

I am learning Entity Bean and I get this error when I am doing my lab. I chose to create a Session Bean for Entity class (for Entity Product). This file is automatically created by NetBeans. But it informs that ProductsFacade.java uses unchecked or unsafe operations.

Here is the code:

@Stateless
public class ProductsFacade implements ProductsFacadeRemote {
    @PersistenceContext(unitName = "NhungBHSE02082_SE0606_AdvJava_Lab10_11-ejbPU")
    private EntityManager em;

    public void create(Products products) {
        em.persist(products);
    }

    public void edit(Products products) {
        em.merge(products);`enter code here`
    }

    public void remove(Products products) {
        em.remove(em.merge(products));
    }

    public Products find(Object id) {
        return em.find(Products.class, id);
    }

    public List<Products> findAll() {
        return em.createQuery("select object(o) from Products as o").getResultList();
    }

    public List<Products> findRange(int[] range) {
        Query q = em.createQuery("select object(o) from Products as o");
        q.setMaxResults(range[1] - range[0]);
        q.setFirstResult(range[0]);
        return q.getResultList();
    }

    public int count() {
        return ((Long) em.createQuery("select count(o) from Products as o").getSingleResult()).intValue();
    }
}
  • 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-06-14T15:45:38+00:00Added an answer on June 14, 2026 at 3:45 pm

    the warning is due to the following methods:

    public List<Products> findAll() {
        return em.createQuery("select object(o) from Products as o").getResultList();
    }
    
    public List<Products> findRange(int[] range) {
        ...
        return q.getResultList();
    }
    

    What happens internally is query.getResultList() returns generic List. Each Object in the List is of type Products. You know that, but compiler doesn’t know. The type can be determined only at runtime. So the compiler shows the warning uncheck or unsafe operation. You can safely ignore this warning.

    If you are really worried, then you can add the annotation @SuppressWarnings("unchecked") to these two methods for the warning to disappear.

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

Sidebar

Related Questions

I am learning ADO.NET entity framework. This is my first example. The datagrid seems
I'm still learning the ropes for Entity expressions, and I have this SQL query
I am just learning Spring3 Validation with Hibernate. I have this class but I
I am learning ASP.NET MVC and Entity Framework. After I learning from this web
I've learning ASP.Net and Entity Framework 4 by a practical example. To trial this,
I am learning to develop windows forms application with Entity Framework using Model View
Learning some VBA. So far, I've constructed this piece of code which should allow
I am learning repository pattern and was reading Repository Pattern with Entity Framework 4.1
I am learning in the visual web developer c#, entity framework, and webservices. I
I come from the web forms world, and I'm learning MVC4 and Entity Framework

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.