Patrick, Maybe the property should be re factored to allow it to be true/false per constraint type, foreignKeyDeferable, uniqueDeferable etc?
Ben On 8/28/07, Patrick Linskey <[EMAIL PROTECTED]> wrote: > That sounds like https://issues.apache.org/jira/browse/OPENJPA-282 > > It should be a trivial fix; we just need to update our Postgres > DBDictionary. > > -Patrick > > On 8/28/07, ben short <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I have upgraded to 1.0.0-SNAPSHOT and see a different error.. > > > > 31 openjpa INFO [main] openjpa.Runtime - Starting OpenJPA > > 1.0.0-SNAPSHOT > > 469 openjpa TRACE [main] openjpa.jdbc.SQL - <t 6206601, conn > > 27182317> executing prepstmnt 23103355 SELECT NULL AS SEQUENCE_SCHEMA, > > relname AS SEQUENCE_NAME FROM pg_class WHERE relkind='S' > > 469 openjpa TRACE [main] openjpa.jdbc.SQL - <t 6206601, conn > > 27182317> [0 ms] spent > > 484 openjpa TRACE [main] openjpa.jdbc.SQL - <t 6206601, conn > > 25086455> executing stmnt 3874616 CREATE TABLE AttributeAndValue (id > > BIGSERIAL NOT NULL, mAttribute VARCHAR(255), mValue VARCHAR(255), > > version INTEGER, mProductInstance BYTEA, PRIMARY KEY (id), UNIQUE > > (mAttribute, mValue) DEFERRABLE) > > 484 openjpa TRACE [main] openjpa.jdbc.SQL - <t 6206601, conn > > 25086455> [0 ms] spent > > Exception in thread "main" <openjpa-1.0.0-SNAPSHOT-r420667:564688 > > nonfatal general error> > > org.apache.openjpa.persistence.PersistenceException: ERROR: syntax > > error at or near "DEFERRABLE" {stmnt 3874616 CREATE TABLE > > AttributeAndValue (id BIGSERIAL NOT NULL, mAttribute VARCHAR(255), > > mValue VARCHAR(255), version INTEGER, mProductInstance BYTEA, PRIMARY > > KEY (id), UNIQUE (mAttribute, mValue) DEFERRABLE)} [code=0, > > state=42601] > > at org.apache.openjpa.jdbc.meta.MappingTool.record( > > MappingTool.java:549) > > at org.apache.openjpa.jdbc.meta.MappingTool.record( > > MappingTool.java:449) > > at > > org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings( > > JDBCBrokerFactory.java:170) > > at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl( > > JDBCBrokerFactory.java:130) > > at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker( > > AbstractBrokerFactory.java:186) > > at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker( > > DelegatingBrokerFactory.java:142) > > at > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager > > (EntityManagerFactoryImpl.java:190) > > at > > org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager > > (EntityManagerFactoryImpl.java:143) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at sun.reflect.NativeMethodAccessorImpl.invoke( > > NativeMethodAccessorImpl.java:39) > > at sun.reflect.DelegatingMethodAccessorImpl.invoke( > > DelegatingMethodAccessorImpl.java:25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at > > org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke > > (AbstractEntityManagerFactoryBean.java:375) > > at $Proxy0.createEntityManager(Unknown Source) > > at com.daisytechnologies.jpatest.Main.insert(Main.java:45) > > at com.daisytechnologies.jpatest.Main.main(Main.java:39) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at sun.reflect.NativeMethodAccessorImpl.invoke( > > NativeMethodAccessorImpl.java:39) > > at sun.reflect.DelegatingMethodAccessorImpl.invoke( > > DelegatingMethodAccessorImpl.java:25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at com.intellij.rt.execution.application.AppMain.main(AppMain.java > > :90) > > Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR: > > syntax error at or near "DEFERRABLE" {stmnt 3874616 CREATE TABLE > > AttributeAndValue (id BIGSERIAL NOT NULL, mAttribute VARCHAR(255), > > mValue VARCHAR(255), version INTEGER, mProductInstance BYTEA, PRIMARY > > KEY (id), UNIQUE (mAttribute, mValue) DEFERRABLE)} [code=0, > > state=42601] > > at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap( > > LoggingConnectionDecorator.java:192) > > at > > org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$800( > > LoggingConnectionDecorator.java:57) > > at > > org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate > > (LoggingConnectionDecorator.java:754) > > at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate( > > DelegatingStatement.java:114) > > at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL( > > SchemaTool.java:1185) > > 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:497) > > ... 20 more > > > > Im using Postgres version 8.1 with Postgres Jdbc driver version > > 8.1-408.jdbc3. > > > > Heres the sql, > > > > CREATE TABLE AttributeAndValue (id BIGSERIAL NOT NULL, mAttribute > > VARCHAR(255), mValue VARCHAR(255), version INTEGER, mProductInstance > > BYTEA, PRIMARY KEY (id), UNIQUE (mAttribute, mValue) DEFERRABLE) > > > > if I remove the DEFERRABLE then the ddl executes without errors. > > > > The Postgres 8.1 docs [1] say.. > > > > DEFERRABLE > > NOT DEFERRABLE > > > > This controls whether the constraint can be deferred. A constraint > > that is not deferrable will be checked immediately after every > > command. Checking of constraints that are deferrable may be postponed > > until the end of the transaction (using the SET CONSTRAINTS command). > > NOT DEFERRABLE is the default. Only foreign key constraints currently > > accept this clause. All other constraint types are not deferrable. > > > > Regards > > > > Ben > > > > On 8/28/07, Patrick Linskey <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > > I think that this is actually a limitation of OpenJPA currently -- > > > OpenJPA ignores unique constraints and some (most?) index definitions > > > when generating a schema. > > > > > > Could you attach the full stack trace to > > > https://issues.apache.org/jira/browse/OPENJPA-340 please? It'll be > > > useful for resolving the issue. > > > > > > -Patrick > > > > > > On 8/28/07, Ignacio Andreu <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > > > > > Regarding the documentation about OpenJPA you can define a unique > > column > > > > with something like that: > > > > > > > > @Entity > > > > @Table(name="ART", [EMAIL PROTECTED](columnNames="TITLE")) > > > > public class Article { > > > > ... > > > > } > > > > > > > > And in XML > > > > > > > > <entity class="org.mag.Article"> > > > > <table name="ART"> > > > > <unique-constraint> > > > > <column-name>TITLE</column-name> > > > > </unique-constraint> > > > > </table> > > > > ... > > > > </entity> > > > > > > > > For more information see the "Unique Constraints" section [1] > > > > > > > > - Ignacio > > > > > > > > > > > > [1] > > > > > > http://openjpa.apache.org/docs/latest/manual/manual.html#jpa_overview_mapping_unq > > > > > > > > On 8/28/07, ben short <[EMAIL PROTECTED]> wrote: > > > > > > > > > > Hi, > > > > > > > > > > I am trying to use the @UniqueConstraint annotation but get the > > > > > following error message.. > > > > > > > > > > OpenJPA does not yet support the @UniqueConstraint annotation. > > > > > > > > > > Is that any plan to implement this feature in the near future? Can I > > > > > define the mapping for the class that I'm trying to annotate in xml > > > > > rather than use the annotations to use the UniqueConstraint feature? > > > > > > > > > > Regards > > > > > > > > > > Ben Short > > > > > > > > > > > > > > > > > > -- > > > Patrick Linskey > > > 202 669 5907 > > > > > > > > > -- > Patrick Linskey > 202 669 5907 >