You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Kevin Viet <vi...@activia.net> on 2002/12/06 11:33:44 UTC

SQL Error

Hello I want to create a mapping with this kind of configuration : 

CREATE TABLE A	 (
	name VARCHAR(50),
	PRIMARY KEY (name)
);

CREATE TABLE B (
	name VARCHAR(50),
	a    VARCHAR(50),
	PRIMARY KEY (name, a),
	FOREIGN KEY (a) REFERENCES A (name)
);

CREATE TABLE C (
	name VARCHAR(50),
	a VARCHAR(50),
	PRIMARY KEY (name, a),
	FOREIGN KEY (a) REFERENCES A (name)
);

CREATE TABLE BtoC
(ouai
	b VARCHAR(50) PRIMARY KEY
	c VARCHAR(50) PRIMARY KEY,
	a VARCHAR(50) PRIMARY KEY,

	FOREIGN KEY (b, a) REFERENCES B (b, a),
	FOREIGN KEY (c, a) REFERENCES C (c, a)
)

<class-descriptor class="B" table="B">
        <field-descriptor id="1" name="name" column="name" 			 
jdbc-type="VARCHAR" primarykey="true"/>
        <field-descriptor id="2" name="a" column="a" 			 
jdbc-type="VARCHAR" primarykey="true"/>

	<collection-descriptor>
            <fk-pointing-to-this-class column="b"/>
            <fk-pointing-to-this-class column="a"/>
            <fk-pointing-to-element-class column="c"/>
            <fk-pointing-to-this-class column="a"/>		
	
	</collection-descriptor>
</class-descriptor>
<class-descriptor class="C" table="C">
	<field-descriptor id="1" name="name" column="name" 	 			 
jdbc-type="VARCHAR" primarykey="true"/>
	<field-descriptor id="2" name="name" column="name" 	 			 
jdbc-type="VARCHAR" primarykey="true"/>	
</class-descriptor>


With this configuration I get an SQL error :
INSERT INTO dsclusters (b,a,c,a) VALUES ( 'b','a','c','a' ) 
ERROR:  Attribute 'a' specified more than once

Is this due to the <collection-descriptor> element in class b ?

If i add a column in BtoC table that reference the a column of table C,
that works fine, so i can imagine that this configuration is a
limitation of OJB, am I wrong ?







-- 
Kevin Viet <vi...@activia.net>
ActiVia Networks