geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacek Laskowski" <ja...@laskowski.net.pl>
Subject Re: EntityExistsException: Attempt to persist detached object
Date Tue, 27 Nov 2007 12:56:43 GMT
On Nov 27, 2007 1:43 PM, maho77 <m.hoffmann@mvolution.de> wrote:

> thanks, I did it like you advised and I worked. But not as expected. I
> received the following exception:
> <openjpa-1.0.0-r420667:568756 nonfatal store error>
> org.apache.openjpa.util.StoreException: Attempt to update the sequence table
> "ID_GENERATOR" failed.  The sequence table is typically created when you run
> the mappingtool's refresh action on any datastore identity class. If you
> have not run the mappingtool but want to create the sequence table, run:
> java org.apache.openjpa.jdbc.kernel.TableJDBCSeq -action add
...
> So according to this exception I changed the table to:
> CREATE TABLE ID_GENERATOR (
>         name0 VARCHAR(100) NOT NULL,
>         id_value INTEGER UNSIGNED NOT NULL,
>         PRIMARY KEY(name0)
> );
>
> And it worked without any changes in the annotation.
>
> Can you explain this? Thank you very much.

You can specify whether a schema for your entities should be generated
in persistence.xml of your application -
openjpa.jdbc.SynchronizeMappings. Try the following to fix it:

<?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 ...>
    <properties>
      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
    </properties>
  </persistence-unit>
</persistence>

You may also want to run it with the more verbose property value:

  <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(SchemaAction='add,deleteTableContents')"/>

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Mime
View raw message