I wish I could say it :(

Ok I will try to explain a lil more what I'm doing.
It's just a POC so it's quite simple.
Database : MYSQL with 2 tables Customer and Address where Customer has a FR
on Address.

I create the entities like this :

@Entity
@Table(name="customer")
public class Customer implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @Column(name="ID")
        private int id;

...

-----------------------------

I create the facade kind of DAO

@Stateless
public class CustomerFacade extends AbstractFacade<Customer> {
        @PersistenceContext(unitName = "jpaPOC")
    private EntityManager em;
...

----------------------------

My main (big summary without exception)

p.load(new FileInputStream(new File(propertiesPath)));
Context context = new InitialContext(p);
customerFacade = (CustomerFacade) context.lookup("CustomerFacadeLocalBean");
List<Customer> customerList = customerFacade.findAll();
System.out.println("customerList.size : "+customerList.size());
for (Customer customer : customerList) {
        System.out.println(customer.getFirstName()+" "+customer.getLastName()+"
from "+customer.getAddress().getCity());
}

For now everything work well if I run it as a java app.
I create a method in my main to just retrieve the list.
I just copy paste the code and return the list to be sure it's the same.
--------------------------------

Now i create a servlet

public class adminConsole extends HttpServlet {
        private static final long serialVersionUID = 1L;
    
        ....

        protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
                PrintWriter out = response.getWriter();
                MainJPAPoc m = new MainJPAPoc();
                List<Customer> customerList = m.getCustomer();
                out.println("customerList.size : "+customerList.size());
                for (Customer customer : customerList) {
                        out.println(customer.getFirstName()+" 
"+customer.getLastName()+" from
"+customer.getAddress().getCity());
                }
        }

I know it's an ugly way no worries, it's just to be sure i use code that is
working for a java app.

Here is the zip of my project

webJpaPoc.zip
<http://openejb.979440.n4.nabble.com/file/n4658423/webJpaPoc.zip>  

I don't get any error in the stactrace. The list is just empty.
I feel like it's not going in the databse.

Thanks a lot for your help and time !



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Adapt-ejb-run-on-java-app-to-web-app-tp4658420p4658423.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to