persistence@glassfish.java.net

Getting error Glassfish + JPA + Jersey

From: Roan Brasil Monteiro <roanbrasil_at_gmail.com>
Date: Fri, 16 Oct 2009 14:11:37 -0300

Dont persist and dont show error . The tables are created but when I persist
I cannot and got it. Bellow is my code. The table Place is created but dont
persist. Why?

My class Test.java

@Path("/test")
public class Test {



     @PersistenceUnit(unitName = "citespacePU")
     EntityManagerFactory emf;



       @GET
       @Produces("text/plain")
       public String getIt() throws NamingException {
           StringBuilder strb = new StringBuilder();

           Place p = new Place();
           p.setName("Roan");


           EntityManager em = emf.createEntityManager();


           UserTransaction utx = getUtx();
           try {
               utx.begin();
               em.persist(p);
               utx.commit();
           } catch (Exception e) {
               try {
                   utx.rollback();
               } catch (SystemException se) {
                   throw new WebApplicationException(se);
               }
               throw new WebApplicationException(e);
           } finally {
               em.close();
           }


persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="citespacePU" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>jdbc/TestDS</jta-data-source>
    <properties>
         <property name="hibernate.hbm2ddl.auto" value="update"/>
         <property name="hibernate.connection.characterEncoding"
value="UTF-8"/>
    </properties>
  </persistence-unit>
</persistence>


-- 
Atenciosamente,
Roan Brasil Monteiro
http://roanbrasil.wordpress.com/