Have you read this?
http://tapestry.apache.org/integrating-with-jpa.html

You should @Inject EntityManager, if you do things right you won't have to
create EntityManager instances yourself.

Also, saying that you have NPE, it would be nice if you provide us a
stacktrace.


On Fri, Oct 11, 2013 at 2:48 PM, Andreas Ernst <a...@ae-online.de> wrote:

> Hi,
>
> i am playing with JPA, but there is no useful information about that. A
> simple example to display a database table.
>
> The entities class is in the right package entities. I did not added
> something to the AppModule class. The persistence.xml exists.
>
> Customer.tml
>
> <html t:type="layout" title="Customer"
>       
> xmlns:t="http://tapestry.**apache.org/schema/tapestry_5_**3.xsd<http://tapestry.apache.org/schema/tapestry_5_3.xsd>
> "
>       xmlns:p="tapestry:parameter">
>   <table t:type="grid" source="customers"/>
> </html>
>
>
> Customers.class
>
> public class Customers {
>
>   @Property
>   private Customer customer;
>   private EntityManagerFactory factory;
>   private EntityManager entityManager;
>   @Inject
>   private Logger logger;
>   @Inject
>   private BeanModelSource beanModelSource;
>   @Inject
>   private Messages messages;
>
>   @Log
>   public List<Customers> getCustomers() {
>     factory = Persistence.**createEntityManagerFactory("**
> de.aeits_TapestryWeb_war_1.0-**SNAPSHOTPU");
>     entityManager = factory.createEntityManager();
>     return entityManager.**createNamedQuery("Customer.**
> findAll").getResultList();
>   }
> }
>
>
> What about the DAO and DAOImpl there are no informations how to use this
> classes with a simple query page.
>
> In all docus i found only 
> 'entityManager.**createNamedQuery("Customer.**findAll").getResultList();'
> is needed, but i get a null pointer expection.
>
> Thanks
> Andreas
> --
> ae | Andreas Ernst | IT Spektrum
> Postfach 5, 65612 Beselich
> Schupbacher Str. 32, 65614 Beselich, Germany
> Tel: +49-6484-91002 Fax: +49-6484-91003
> a...@ae-online.de | www.ae-online.de
> www.tachyon-online.de
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@tapestry.**apache.org<users-unsubscr...@tapestry.apache.org>
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Reply via email to