Hi
Thanks for responding the stack trace is as follows:
<error message="Table already exists: ADDITIONALINFO in statement
[CREATE TABLE AdditionalInfo] {stmnt 484661004 CREATE TABLE
AdditionalInfo (id INTEGER NOT NULL IDENTITY, notes VARCHAR(255))}
[code=-21, state=S0001]"
type="org.apache.openjpa.persistence.PersistenceException"><openjpa-1.2.1-r752877:753278
nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: Table already exists:
ADDITIONALINFO in statement [CREATE TABLE AdditionalInfo] {stmnt 484661004
CREATE TABLE AdditionalInfo (id INTEGER NOT NULL IDENTITY, notes VARCHAR(255))}
[code=-21, state=S0001]
at
org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:553)
at
org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:453)
at
org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
at
org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119)
at
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:189)
at
org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
at
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
at pcm.db.connection.DatabaseConnection.connectionStartup(Unknown
Source)
at pcm.db.connection.DatabaseConnectionTest.connectionStartup(Unknown
Source)
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Table
already exists: ADDITIONALINFO in statement [CREATE TABLE
AdditionalInfo] {stmnt 484661004 CREATE TABLE AdditionalInfo (id INTEGER
NOT NULL IDENTITY, notes VARCHAR(255))} [code=-21, state=S0001]
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access
$700(LoggingConnectionDecorator.java:57)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator
$LoggingConnection
$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:762)
at
org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:114)
at
org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1191)
at
org.apache.openjpa.jdbc.schema.SchemaTool.createTable(SchemaTool.java:949)
at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:526)
at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:344)
at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:321)
at
org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:501)
</error>
I have removed the schema option, and this now appears to work:
<property name="openjpa.jdbc.Schema" value="PCM"/>
How can I use a schema effectively with HSQLDB?
Thanks
David
On Mon, 2009-10-12 at 19:15 +0200, Miłosz Tylenda wrote:
> David,
>
> Please also check whether you fall in the case described in OPENJPA-842 [1].
> Basically, there is a problem when a table exists in public (default) schema
> and another table with the same name exists in another schema.
>
> [1] https://issues.apache.org/jira/browse/OPENJPA-842
>
> Greetings,
> Milosz
>
> > David-
> >
> > I'm not quire sure whats going on, but do you have a stack showing the
> > failure?
> >
> > Thanks,
> > Rick
> >
> > On Sun, Oct 11, 2009 at 6:18 PM, David Beer
> > <[email protected]>wrote:
> >
> > > Hi All
> > >
> > > I am trying to create an application using HSQLDB 1.8.1. I have created
> > > a server database for testing. The problem seems to be that if I run the
> > > test a second time, it fails saying table already created. Well I would
> > > expect the table to be created as I didn't tell it drop them.
> > >
> > > The thing is that surely it should only be updating the tables if there
> > > is a change. Not trying to create them each time.
> > >
> > > I am using openjpa 1.2.1. Here is a copy of my persistence.xml,
> > > hopefully someone can see where I am going wrong.
> > >
> > > <?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="PCM-PU" transaction-type="RESOURCE_LOCAL">
> > >
> > > <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> > > <class>pcm.jpa.AddressBook</class>
> > > <class>pcm.jpa.Contact</class>
> > > <class>pcm.jpa.Address</class>
> > > <class>pcm.jpa.ContactInfo</class>
> > > <class>pcm.jpa.AdditionalInfo</class>
> > > <class>pcm.jpa.IM</class>
> > > <properties>
> > > <property name="openjpa.ConnectionPassword" value=""/>
> > > <property name="openjpa.ConnectionDriverName"
> > > value="org.hsqldb.jdbcDriver"/>
> > > <property name="openjpa.ConnectionUserName" value="sa"/>
> > > <!--<property name="openjpa.ConnectionURL"
> > > value="jdbc:hsqldb:file:./data/pcm"/>-->
> > > <property name="openjpa.ConnectionURL"
> > > value="jdbc:hsqldb:hsql://localhost/xdb"/>
> > > <property name="openjpa.Log" value="DefaultLevel=WARN,
> > > Runtime=INFO, Tool=INFO, SQL=TRACE"/>
> > > <property name="openjpa.jdbc.SynchronizeMappings"
> > > value="buildSchema(ForeignKeys=true)"/>
> > > <property name="openjpa.jdbc.DBDictionary"
> > > value="org.apache.openjpa.jdbc.sql.HSQLDictionary"/>
> > > <property name="openjpa.jdbc.Schema" value="PCM"/>
> > > </properties>
> > > </persistence-unit>
> > > </persistence>
> > >
> > > The other issue I am having is that it seems to be ignoring the scheam
> > > value entered and creating the tables in the PUBLIC schema.
> > >
> > > I am simply connecting to the database creating my EntityManager and
> > > then disconnecting.
> > >
> > >
> > > --
> > > Thanks
> > >
> > > David
> > >
> > >
> >