CMP Entity bean and Primary key - Mailing list pgsql-jdbc
From | Habib Seifzadeh |
---|---|
Subject | CMP Entity bean and Primary key |
Date | |
Msg-id | 4297836F.4050104@yahoo.com Whole thread Raw |
List | pgsql-jdbc |
Hi there, I use NetBeans 4.1EA and J2EE RI. I have no problem with creating CMP Entity beans using Pointbase or MySQL database server but when I want to deploy CMP Entity bean which is mapped to a PostgreSQL table, JCodeGenerator of Application server catches an Exception. Unfortunately, I could find only one message that it's sender have my problem and there was no reasonable reply to that. the message is: > Having a strange problem with Sun studio 4 update 1 talking to postgreSQL > 7.3. (Redhat version) > > Using the latest Postgres JDBC driver (both latest stable and dev > releases)- in Sun studio I'm having problems mapping my container manager > persitence entity beans to postgres tables. > > I make a database schema and entity bean from the postgres datasource > (everything's fine at this stage) but when I try to map > the ejb fields to tables in the postgres schema, for deployment, the > dialogue reports "Table 'x' has no primary keys defined" > > I've checked my keys and indexes and I definitley have a primary key > defined. Is there something I'm missing? > > I have the database in MySQL also and it works fine with Sun - but I'd > much > rather have a postgres backend. > > I've searched the web and newsgroups and can find hardly any information > on > this topic, your help would be very much appreciated > > > regards > Nuno D. Leitao and here is some information about my databse and app: 1. the database name is habib and is in localhost. 2. the table is student and here is it's columns: CREATE TABLE student ( id int2 NOT NULL, name varchar(10), CONSTRAINT student_pkey PRIMARY KEY (id) ) WITH OIDS; ALTER TABLE student OWNER TO habib; of course, I checked WITHOUT OIDS, but the problem remains. 3. here is public_Module1Ejb.dbschema : <?xml version="1.0" encoding="UTF-8" ?> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.SchemaElement" ID="org.netbeans.modules.dbschema.SchemaElement-255648917"> <impl> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.SchemaElementImpl" ID="org.netbeans.modules.dbschema.jdbcimpl.SchemaElementImpl1222210"> <tables> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.DBElementsCollection" ID="org.netbeans.modules.dbschema.jdbcimpl.DBElementsCollection7291167"> <owner> <OBJECT REFERENCE="org.netbeans.modules.dbschema.jdbcimpl.SchemaElementImpl1222210"/> </owner> <_elms> <ARRAY SIZE="1" CLASS="PRIMITIVE" ROWCLASS="com.sun.forte4j.modules.dbmodel.TableElement"> <ROW ROW="0"> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.TableElement" ID="org.netbeans.modules.dbschema.TableElement-393801032"> <impl> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.TableElementImpl" ID="org.netbeans.modules.dbschema.jdbcimpl.TableElementImpl9164520"> <element> <OBJECT REFERENCE="org.netbeans.modules.dbschema.TableElement-393801032"/> </element> <table>student</table> <keys> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.DBElementsCollection" ID="org.netbeans.modules.dbschema.jdbcimpl.DBElementsCollection19377347"> <owner> <OBJECT REFERENCE="org.netbeans.modules.dbschema.jdbcimpl.TableElementImpl9164520"/> </owner> <_elms> <OBJECT/> </_elms> <_template> <ARRAY SIZE="0" CLASS="PRIMITIVE" ROWCLASS="com.sun.forte4j.modules.dbmodel.KeyElement"> </ARRAY> </_template> </OBJECT> </keys> <_name> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.DBIdentifier" ID="org.netbeans.modules.dbschema.DBIdentifier15411030"> <name>student</name> </OBJECT> </_name> <indexes> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.DBElementsCollection" ID="org.netbeans.modules.dbschema.jdbcimpl.DBElementsCollection16408207"> <owner> <OBJECT REFERENCE="org.netbeans.modules.dbschema.jdbcimpl.TableElementImpl9164520"/> </owner> <_elms> <ARRAY SIZE="1" CLASS="PRIMITIVE" ROWCLASS="com.sun.forte4j.modules.dbmodel.IndexElement"> <ROW ROW="0"> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.IndexElement" ID="org.netbeans.modules.dbschema.IndexElement886714089"> <impl> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.IndexElementImpl" ID="org.netbeans.modules.dbschema.jdbcimpl.IndexElementImpl23515932"> <element> <OBJECT REFERENCE="org.netbeans.modules.dbschema.IndexElement886714089"/> </element> <_unique>false</_unique> <_name> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.DBIdentifier" ID="org.netbeans.modules.dbschema.DBIdentifier20723536"> <name>student_pkey</name> </OBJECT> </_name> <columns> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.DBElementsCollection" ID="org.netbeans.modules.dbschema.jdbcimpl.DBElementsCollection8628573"> <owner> <OBJECT REFERENCE="org.netbeans.modules.dbschema.jdbcimpl.TableElementImpl9164520"/> </owner> <_elms> <ARRAY SIZE="1" CLASS="PRIMITIVE" ROWCLASS="com.sun.forte4j.modules.dbmodel.ColumnElement"> <ROW ROW="0"> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.ColumnElement" ID="org.netbeans.modules.dbschema.ColumnElement2124155921"> <impl> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.ColumnElementImpl" ID="org.netbeans.modules.dbschema.jdbcimpl.ColumnElementImpl18430186"> <element> <OBJECT REFERENCE="org.netbeans.modules.dbschema.ColumnElement2124155921"/> </element> <_isNullable>false</_isNullable> <_length> <OBJECT CLASS="java.lang.Integer" ID="java.lang.Integer2"> <value>2</value> </OBJECT> </_length> <_name> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.DBIdentifier" ID="org.netbeans.modules.dbschema.DBIdentifier12879730"> <name>id</name> </OBJECT> </_name> <_precision> <OBJECT REFERENCE="java.lang.Integer2"/> </_precision> <_type>5</_type> <_scale> <OBJECT CLASS="java.lang.Integer" ID="java.lang.Integer0"> <value>0</value> </OBJECT> </_scale> </OBJECT> </impl> <declaringTable> <OBJECT REFERENCE="org.netbeans.modules.dbschema.TableElement-393801032"/> </declaringTable> </OBJECT> </ROW> </ARRAY> </_elms> <_template> <ARRAY SIZE="0" CLASS="PRIMITIVE" ROWCLASS="com.sun.forte4j.modules.dbmodel.ColumnElement"> </ARRAY> </_template> </OBJECT> </columns> <tei> <OBJECT REFERENCE="org.netbeans.modules.dbschema.jdbcimpl.TableElementImpl9164520"/> </tei> </OBJECT> </impl> <declaringTable> <OBJECT REFERENCE="org.netbeans.modules.dbschema.TableElement-393801032"/> </declaringTable> </OBJECT> </ROW> </ARRAY> </_elms> <_template> <ARRAY SIZE="0" CLASS="PRIMITIVE" ROWCLASS="com.sun.forte4j.modules.dbmodel.IndexElement"> </ARRAY> </_template> </OBJECT> </indexes> <isTable>true</isTable> <columns> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.DBElementsCollection" ID="org.netbeans.modules.dbschema.jdbcimpl.DBElementsCollection7617295"> <owner> <OBJECT REFERENCE="org.netbeans.modules.dbschema.jdbcimpl.TableElementImpl9164520"/> </owner> <_elms> <ARRAY SIZE="2" CLASS="PRIMITIVE" ROWCLASS="com.sun.forte4j.modules.dbmodel.ColumnElement"> <ROW ROW="0"> <OBJECT REFERENCE="org.netbeans.modules.dbschema.ColumnElement2124155921"/> </ROW> <ROW ROW="1"> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.ColumnElement" ID="org.netbeans.modules.dbschema.ColumnElement1204524033"> <impl> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.jdbcimpl.ColumnElementImpl" ID="org.netbeans.modules.dbschema.jdbcimpl.ColumnElementImpl9988469"> <element> <OBJECT REFERENCE="org.netbeans.modules.dbschema.ColumnElement1204524033"/> </element> <_isNullable>true</_isNullable> <_length> <OBJECT CLASS="java.lang.Integer" ID="java.lang.Integer10"> <value>10</value> </OBJECT> </_length> <_name> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.DBIdentifier" ID="org.netbeans.modules.dbschema.DBIdentifier3379466"> <name>name</name> </OBJECT> </_name> <_precision> <OBJECT REFERENCE="java.lang.Integer10"/> </_precision> <_type>12</_type> <_scale> <OBJECT REFERENCE="java.lang.Integer0"/> </_scale> </OBJECT> </impl> <declaringTable> <OBJECT REFERENCE="org.netbeans.modules.dbschema.TableElement-393801032"/> </declaringTable> </OBJECT> </ROW> </ARRAY> </_elms> <_template> <ARRAY SIZE="0" CLASS="PRIMITIVE" ROWCLASS="com.sun.forte4j.modules.dbmodel.ColumnElement"> </ARRAY> </_template> </OBJECT> </columns> </OBJECT> </impl> </OBJECT> </ROW> </ARRAY> </_elms> <_template> <ARRAY SIZE="0" CLASS="PRIMITIVE" ROWCLASS="com.sun.forte4j.modules.dbmodel.TableElement"> </ARRAY> </_template> </OBJECT> </tables> <_name> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.DBIdentifier" ID="org.netbeans.modules.dbschema.DBIdentifier24601638"> <name>habib [habib on public]</name> </OBJECT> </_name> <_driverVersion>PostgreSQL 7.4.5 JDBC3 with SSL (build 216)</_driverVersion> <_catalog> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.DBIdentifier" ID="org.netbeans.modules.dbschema.DBIdentifier22025519"> <name>habib</name> </OBJECT> </_catalog> <element> <OBJECT REFERENCE="org.netbeans.modules.dbschema.SchemaElement-255648917"/> </element> <_databaseProductVersion>7.4.5</_databaseProductVersion> <_driver>org.postgresql.Driver</_driver> <_databaseProductName>PostgreSQL</_databaseProductName> <_schema> <OBJECT CLASS="com.sun.forte4j.modules.dbmodel.DBIdentifier" ID="org.netbeans.modules.dbschema.DBIdentifier10417049"> <name>public</name> </OBJECT> </_schema> <_url>jdbc:postgresql://localhost:5432/habib</_url> <_driverName>PostgreSQL Native Driver</_driverName> <_username>habib</_username> </OBJECT> </impl> <versionNo>2</versionNo> </OBJECT> 4. And finally here is sun-cmp-mappings.xml : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sun-cmp-mappings PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 OR Mapping//EN" "http://www.sun.com/software/appserver/dtds/sun-cmp-mapping_1_2.dtd"> <sun-cmp-mappings> <sun-cmp-mapping> <schema>public_Module1Ejb</schema> <entity-mapping> <ejb-name>Student</ejb-name> <table-name>student</table-name> <cmp-field-mapping> <field-name>id</field-name> <column-name>student.id</column-name> <fetched-with> <default/> </fetched-with> </cmp-field-mapping> <cmp-field-mapping> <field-name>name</field-name> <column-name>student.name</column-name> <fetched-with> <default/> </fetched-with> </cmp-field-mapping> </entity-mapping> </sun-cmp-mapping> </sun-cmp-mappings> Please help me, Thank you in advance, Habib
pgsql-jdbc by date: