Discussion:
[Middlegen-user] Unwanted PK problem!
Tim Cockle
2005-09-02 09:29:01 UTC
Permalink
Hi,

I hope someone out there can help as I am stuck on this one! I have a
set of tables, form, part and question. The logic is that forms are a
collection of parts and parts are a collection of questions.

The database I am using is postgresql and the tables are created with
the following SQL (I have removed some details for clarity).

CREATE TABLE form(
"form_id" INT NOT NULL,
"form_name" VARCHAR(255) NOT NULL,
?
PRIMARY KEY("form_id")
) ;

CREATE TABLE part(
"part_id" INT NOT NULL,
"part_name" VARCHAR(255) NOT NULL,
?
"form_id_fk" INT,
PRIMARY KEY("part_id"),
FOREIGN KEY ("form_id_fk") REFERENCES "form"("form_id")
);

CREATE TABLE question(
"question_id" INT NOT NULL,
"question_text" VARCHAR(255) NOT NULL,
?
"part_id_fk" INT,
"form_id_fk" INT,
PRIMARY KEY("question_id"),
FOREIGN KEY ("part_id_fk") REFERENCES "part"("part_id"),
FOREIGN KEY ("form_id_fk") REFERENCES "form"("form_id")
);

The middlegen tag in ant is as follows:

<middlegen
appname="${name}"
prefsdir="${src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${databaseSource}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema=""
<table name="question"/>
<table name="part"/>
<table name="form"/>

<cmp20
destination="${src.gen-code.dir}"
package="alpha.formEntities"
interfacepackage="alpha.formEntitiesInterfaces"
jndiprefix="${unique.name}"
pkclass="false"
dataobject="false"
viewtype="local"
mergedir="${basedir}/src/middlegen"
readonly="false"
fkcmp="false"
guid="true"
<finders>
<and>
<pk/>
<not>
<fk/>
</not>
<not>
<notkey/>
</not>
</and>
</finders>

<sequenceblock
blocksize="5"
retrycount="2"
table="SEQ_BLOCK"
package="alpha.miscEntities"
interfacepackage="alpha.miscEntitiesInterfaces"
/>

<jboss/>
</cmp20>
</middlegen>

The problem is this, form and question both an Integer as the primary
key however part uses a PartPK class even though cmp20 has
pkclass="false" set.

HeLp!!!!

Thanks,

Tim

Loading...