I want to display a list of users in an XHTML page. I'm sending a request from my managedBean to the Business through an EJB (3.0) then another request to the DAO still through an EJB (3.0). I'm using JPA 2 and a MySQL database with an entity manager.
I'm sending the following request to my database
@Remote(IDaoUser.class)
@Stateless
Public class DaoUser implements IDaoUser
@PersitenceContext(unitName = "persistence_unit")
Private EntityManager em;
@Override
Public List<User> getAll() {
Query query = em.createQuery("SELECT u FROM User u");
List<User> users = query.getResultList();
return users;
}
At that point everything's fine and I get all my users in my list with all attributes especially id (primary key). My user class has one attribute (birthdate) and inherits from a super class Parent (name, forename, mail, phone...) which inherits again from another class called Who which has just one attribute called id (the primary key). Then I return my List (users) to the business through an EJB and once in the business I realise all the id attributes are 0. I kept all the others attributes (name, forename...) except ids and I can't figure out why I'm losing these values. There are well stored in my List in the DAO but all changed to 0 once in the business.
Here is my business class which is very simple
@Remote(IBusinessUser.class)
@Stateless
Public class BusinessUser implements IBusinessUser
@EJB
private IDaoUser proxy;
@Override
Public List<User> getAll() {
List<User> users = proxy.getAll();
return users;
}