db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thierry Peng <p...@glue.ch>
Subject @catalog problem
Date Thu, 15 Jul 2010 06:51:01 GMT
Hello derbyusers

I'm using an in-memory derby 10.6.1 db for our testng tests to run 
against with the ddl-generation flag set. The persistenceprovider is 
eclipselink 2.0.2.
It's working fine as long in every entity used the catalog attribute is 
defined, for example:
@Entity
@Table(name = "KHH_BFS_MUNICIPALITY", catalog="KHH")
public class KhhBfsMunicipality implements java.io.Serializable

If I remove this, and I have to because not every DB Schema is named khh 
but maybe also name khh_prod or whatever, the derby startup fails with 
the following error:

[EL Warning]: 2010-07-15 
08:14:27.781--ServerSession(14298351)--Exception [EclipseLink-4002] 
(Eclipse Persistence Services - 2.0.2.v20100323-r6872): 
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Constraint 
'KHHBFSMNCNTNBBRVTN' is invalid: there is no unique or primary key 
constraint on table '"APP"."KHH_BFS_CANTON"' that matches the number and 
types of the columns in the foreign key.
Error Code: 30000
Call: ALTER TABLE KHH_BFS_MUNICIPALITY ADD CONSTRAINT KHHBFSMNCNTNBBRVTN 
FOREIGN KEY (CANTON_ABBREVIATION) REFERENCES KHH_BFS_CANTON 
(CANTON_ABBREVIAT
ION)
Query: DataModifyQuery(sql="ALTER TABLE KHH_BFS_MUNICIPALITY ADD 
CONSTRAINT KHHBFSMNCNTNBBRVTN FOREIGN KEY (CANTON_ABBREVIATION) 
REFERENCES KHH_BFS_CA
NTON (CANTON_ABBREVIATION)")


Any hints to solve this problem apart from manually editing the ddl-jdbc 
code and hardcoding it into the tests?

I added also the persistence xml and the generated ddl code (without the 
catalog set)



persistence.xml
  <persistence-unit name="KHHTEST" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
...
    <class>ch.glue.bfs.system.khh.ejb.entities.KhhBfsMunicipality</class>
....
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
    <property name="eclipselink.jdbc.platform" 
value="org.eclipse.persistence.platform.database.DerbyPlatform"/>
        <property name="javax.persistence.jdbc.url" 
value="jdbc:derby:memory:khh;create=true"/>  
        <property name="javax.persistence.jdbc.driver" 
value="org.apache.derby.jdbc.EmbeddedDriver" />
        <property name="eclipselink.target-database" value="Derby"/>   
        <property name="javax.persistence.jdbc.user" value="" />
        <property name="javax.persistence.jdbc.password" value="" />
        <!-- EclipseLink should create the database schema automatically -->
        <property name="eclipselink.ddl-generation" value="create-tables" />
        <property name="eclipselink.ddl-generation.output-mode" 
value="both"/>
    </properties>
</persistence-unit>

generated ddl:
CREATE TABLE KHH_BFS_MUNICIPALITY (MUNICIPALITY_ID INTEGER NOT NULL, 
MUNICIPALITY_NAME VARCHAR(40) NOT NULL, CANTON_ABBREVIATION VARCHAR(255) 
NOT NULL, PRIMARY KEY (MUNICIPALITY_ID))
...
ALTER TABLE KHH_BFS_MUNICIPALITY ADD CONSTRAINT KHHBFSMNCNTNBBRVTN 
FOREIGN KEY (CANTON_ABBREVIATION) REFERENCES KHH_BFS_CANTON 
(CANTON_ABBREVIATION)

greetings

thierry


Mime
View raw message