Hello,
Well I am working with glassfish v2.1 meantime. The tables are created now.
I was settup to derby database. Now the table are created on mysql but I
cannot persist. Can someone told why I am not able to persist and the tables
are blank? The table Place are created on my database jpa but is empty the
table because is not persisted.
this is my Test.java class
@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();
em.persist(p);
.
.
.
and my 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" >
<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>
and my web.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="
http://java.sun.com/xml/ns/javaee" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.server.impl.container.servlet.ServletAdaptor</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>unit:citespacePU</param-name>
<param-value>persistence/citespace</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
<persistence-unit-ref>
<persistence-unit-ref-name>persistence/citespace</persistence-unit-ref-name>
<persistence-unit-name>citespacePU</persistence-unit-name>
</persistence-unit-ref>
<resource-ref>
<res-ref-name>UserTransaction</res-ref-name>
<res-type>javax.transaction.UserTransaction</res-type>
<res-auth>Application</res-auth>
</resource-ref>
</web-app>
--
Atenciosamente,
Roan Brasil Monteiro
http://roanbrasil.wordpress.com/