|Home > Documentation > User's guide > Sample Applications > customer - Simple ejb application with a JPA entity|
The customer sample is a very simple demonstration of a container managed jpa persistence context accessed from a stateless session bean, in turn accessed from a jsp based web app or standalone java client. Since jsps do no support dependency injection through annotations the ejb is looked up in an auxiliary class using the "legacy" java:comp/env jndi context.
CustomerInfo.java is the entity bean that represents the Customer table in the database. By using @Entity, @Table(name = "customer"), and @Id it tells OpenEJB that this is an entity bean, which is representative of the table "customer" and has "customerId" as the primary key. By using these annotations no other configuration is needed inside openejb-jar.xml CustomerInfo.java includes 2 named queries, one is called AllCustomers; the other is called FindCustmer.
Query AllCustmers is used from the stateless session bean called ProcessCustomerSessionBean, which relies on injection of a PersistenceContext; thus we are using container managed persistence contexts, and work is executed in a jta CMT transaction. The ProcessCustomerSessionBean class implements all the methods defined in its local and remote interfaces.
persistence.xml references certain Entity Beans and maps them to use certain database pools. In this case, the entity bean Customer is using the SampleTxDatasourc and SampleNoTxDatasource database pools.
web.xml references the EJB that was created in ProcessCustomerSessionBean.java. By doing this we are allowing the JSP contents inside the WAR to use this EJB via JNDI.
The app is visible at http://localhost:8080/customer/