Am 11.10.13 17:57, schrieb Lenny Primak:
The issue you are facing boils down to this:
EntityManager(s) (EM) in JPA can be created multiple ways.
Tapestry-JPA manages / creates it's own EntityManagerFactory (EMF) and EMs
It also reads persistence.xml on its own, and follows its own rules as far as
having to have entities in a specific package (i.e. xxx.xxx.entities)
When you use @PersistenceContext in Tapestry context, you are actually using
the infrastructure (EMF and EMs) managed by Tapestry-JPA.
Glassfish and the EJB container manage EMFs and EMs on their own, in a
different, completely disconnected way.
But with Tomcat i got the same issue.
If you are using both, you will have two JPA caches and two instances of JPA
infrastructure.
When you do this: factory =
Persistence.createEntityManagerFactory("de.aeits_TapestryWeb_war_1.0-SNAPSHOTPU");
entityManager = factory.createEntityManager();
you are creating EMF by yourself and that will read persistence.xml yet again,
completely disconnected from Tapestry or the EJB container.
Tapestry-JPA is a tricky beast to use when you have more than one PU defined in
your persistence.xml.
It works fine if you define all your classes manually in persistence.xml, but
in case of auto-scanning for entities,
it's hard to get that working correctly (manual configuration / scanning is
required)
In my own projects, I wound up not using tapestry-JPA at all. I just call EJBs
using FlowLogix library
and let EJBs do all my database handling.
I did create a bit of infrastructure (1500 lines of code or so)
that includes GenericDAO, and GridDataSource that call EJBs to get their data
generically.
It's not public now, but if need be I can make it so.
I just take a look at FlowLogix, i there any documentation for that?
I am interested in that, because i will Tapestry use with databases.
Thanks @all.
--
ae | Andreas Ernst | IT Spektrum
Postfach 5, 65612 Beselich
Schupbacher Str. 32, 65614 Beselich, Germany
Tel: +49-6484-91002 Fax: +49-6484-91003
[email protected] | www.ae-online.de
www.tachyon-online.de
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]