users@glassfish.java.net

Web application example with Mysql - Glassfish Mysql datasource

From: <forums_at_java.net>
Date: Sun, 4 Dec 2011 09:21:28 -0600 (CST)

Hi every one,

I am new in Glassfish, I tested a web app with JPA example named WebJpa

I changed the database from Derby to Mysql in Glassfish and it works fine

When a drop the table using mysql query browser I got this erro

javax.servlet.ServletException: Exception [EclipseLink-4002] (Eclipse
Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException Internal Exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table
'appsec.person' doesn't exist Error Code: 1146 Call: SELECT ID, FIRSTNAME,
LASTNAME FROM PERSON Query: ReadAllQuery(referenceClass=Person sql="SELECT
ID, FIRSTNAME, LASTNAME FROM PERSON")
in order to fix it I must to stop glashfish, clean and build the project and
run again.

 

My question is if I am using the following persistence.xml to always create
tables why glassfish just do it only first time after implementation of war?

<?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="web-jpaPU" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>jdbc/__default</jta-data-source>
    <properties>
      <property name="eclipselink.ddl-generation"
value="create-tables"/>
    </properties>
  </persistence-unit>
</persistence>

 

Best regards

 

 


--
[Message sent by forum member 'Mohawk']
View Post: http://forums.java.net/node/870755