geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomasz Mazan <win...@wp.pl>
Subject JPA / postgresql / foreign keys
Date Fri, 28 Sep 2007 12:12:32 GMT

Hi

I configured in my persistence.xml to create (refresh) db schema and enable
constraints / foreign keys on table. Unfortunately JPA creates only tables,
with no foreign keys.

Currently my persistence.xml looks like :

<?xml version="1.0" encoding="UTF-8"?>
<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="CoreDB" transaction-type="JTA">
	
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
		<jta-data-source>DBXAPool</jta-data-source>
  		<non-jta-data-source>CoreDBPool</non-jta-data-source>
 		<class>...</class>
                            ...
		<class></class>
		<properties>
			<property name="openjpa.Sequence"
value="class-table(Table=_SEQ_GENERATOR, UseAliases=true)"/>
 			<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(SchemaAction=refresh,ForeignKeys=true)" /> <!--
buildSchema(ForeignKeys=true) -->
 			<property name="openjpa.jdbc.DBDictionary"
value="postgres(SupportsDeferredConstraints=false)"/>
 			<property name="openjpa.Multithreaded" value="true" />
            <property name="openjpa.TransactionMode" value="managed" />
            <property name="openjpa.NontransactionalRead" value="true" />
            <property name="openjpa.RestoreState" value="all" /> 		
            <property name="openjpa.Optimistic" value="true"/>	
		</properties>
	</persistence-unit>
  
</persistence>

All is working but  constraints. I tried to set
SupportsDeferredConstraints=true, but then I get exception 

Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR: syntax
error at or near "DEFERRABLE" {stmnt 31476688 CREATE TABLE customer (id
INTEGER NOT NULL, number VARCHAR(20) NOT NULL, status SMALLINT NOT NULL,
customer_id INTEGER NOT NULL, PRIMARY KEY (id), UNIQUE (number) 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.refresh(SchemaTool.java:376)
	at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:327)
	at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:497)
	... 81 more



What should I do to make this stuff working ?

Beniamin
-- 
View this message in context: http://www.nabble.com/JPA---postgresql---foreign-keys-tf4534058s134.html#a12939275
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message