openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dyer" <danielwd...@dsl.pipex.com>
Subject Problem using SynchronizeMappings (missing columns)
Date Wed, 12 Dec 2007 01:27:20 GMT
I have an application that was working using Hibernate JPA (standalone,  
not in an EJB container).

I have been trying to convert this to use Open JPA instead.  The  
application uses only JPA annotations (nothing Hibernate-specific).  I  
have managed to fix most of the issues that I have come across but there  
is one thing I am stuck on.  I am trying to get Open JPA to automatically  
create the database tables on application start-up (in the same way that  
the hibernate.hbm2ddl.auto property works).

To achieve this I am using the SycnhronizeMappings property in the  
persistence.xml.  Everything appers to work OK and there are no error  
messages, but when I check the tables in the database (MySQL 5), although  
they have been created, most of the columns are missing.  The only columns  
that are present are the primary keys and most, but not all, of the  
foreign keys.  Simple value columns (e.g. dates and strings mapped with  
@Column) are not there.

This is what my persistence.xml looks like.

<persistence 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"
              version="1.0">
   <persistence-unit name="myproject">
     <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>

     <jar-file>myproject-core.jar</jar-file>

     <properties>
       <property name="openjpa.ConnectionDriverName"  
value="com.mysql.jdbc.Driver" />
       <property name="openjpa.ConnectionURL"  
value="jdbc:mysql://localhost/myproject" />
       <property name="openjpa.ConnectionUserName" value="myproject" />
       <property name="openjpa.ConnectionPassword" value="myproject" />
       <property name="openjpa.jdbc.SynchronizeMappings"  
value="buildSchema"/>
     </properties>

   </persistence-unit>
</persistence>

I have tried numerous variations on "buildSchema" and its parameters that  
I found on the web, but the result is the same.

Does anybody have any ideas what I'm doing wrong?  Am I wrong to assume  
that SynchronizeMappings is supposed to be equivalent to  
hibernate.hbm2ddl.auto?  I can provide more details if necessary.

Thanks,

Dan.

-- 
Daniel Dyer
http://www.uncommons.org

Mime
View raw message