jpa: query and transaction

From: Tore Halset (halse..vv.ntnu.no)
Date: Fri Mar 03 2006 - 05:39:39 EST

  • Next message: Andrus Adamchik: "Re: jpa: query and transaction"

    Hello.

    I just checked in a implementation of EntityManager.createNamedQuery
    (String name) and a jpa EntiryTransaction that wrapps around a
    cayenne transaction.

    I have used this to switch out DataContext with EntityManager in a
    small project here. It is a ultra-simple tapestry4 interface for
    managing users for the james mailserver. Just adding/editing/deleting
    users. All queries are (now) done using named queries.

    How are the EntityManager are supposed to be created? Perhaps we need
    a connection between PersistenceUnitInfo and cayenne? And how should
    we provide jpa with a transaction? This is what I am currently doing
    in tapestry-visit.

                 // TODO: do this the correct way
                 PersistenceUnitInfo pui = new MockPersistenceUnitInfo();
                 EntityManagerFactory emf = new CjpaEntityManagerFactory
    (pui);
                 EntityManager em = emf.createEntityManager();
                 // TODO: how to do transaction stuff?
                 ((JpaEntityManager) em).setTransaction(new
    CjpaEntityTransaction(Transaction
                         .noTransaction()));

    At last, one maven newbie question. How can I build a jar-file from
    the cayenne-jpa project?

    Regards,
      - Tore.



    This archive was generated by hypermail 2.0.0 : Fri Mar 03 2006 - 05:39:52 EST