Error Mapping Entity Bean's fields with Postgresql's tables
Hi all,
I have problem using Sun studio 4 to map
Entity Bean's fields with Postgresql's tables.
First I capture the DB Schema of the two
tables that I have to map.
Then I create two related Entity Beans.
When I try to map beans' fields with
DB columns, Sun One prints that one of
the two table hasn't defined the primary key.
It seems that the problem resides in the
DB Schema.
I don't understand if this is due to a "general"
bug of Sun One Studio or if it's a "particular"
problem that Sun One Studio has only with
DB Postgresql or ... if I'am wrong :-)
Many thanks in advance
Moreno
Neither the Sun ONE App Server 7 nor the persistence manager allow CMP mapping to a table without a primary key. If the table you are mapping does not have a primary key, you must create one. If it does indeed have a primary key, but it doesn't show up in the DB Schema, then the problem probably comes from either the DB Schema module or from the JDBC driver you used to capture the schema.
Can you please give me more details, such as the text of the error message, the DDL SQL text, and the driver you are using.
Thank you,
Jane Sokolow
Hi Jane,
I'm using DB Postgresql, the driver Class is
org.postgresql.Driver.
I have to map two tables.
The first one has got a compound primary key
(two columns for PK).
The second one (the table that gives me
the problem) has a single column PK.
I noticed that the Capture Schema of Sun One
always fails ONLY with tables that have a single
column PK.
If I try to map the Entity Bean with the second
table, Sun One print that:
"Table <table name> hasn't got a Primary Key".
To go round the bug, I have to map the Entity Bean with the table that doesn't give the problem and
only after this mapping I can map the second
bean.
I'll try to use the Capture Schema of Sun One
Application Server 7, hoping that it runs :-)
Moreno
You may also want to verify that th JDBC driver you are using is the most current. Another thing to do is to use the database functionality from the runtime tab to connect to your database, this way you can verify that the database metadata is indeed correct.
> Hi Jane,
> I'm using DB Postgresql, the driver Class is
> org.postgresql.Driver.
> I have to map two tables.
> The first one has got a compound primary key
> (two columns for PK).
> The second one (the table that gives me
> the problem) has a single column PK.
>
> I noticed that the Capture Schema of Sun One
> always fails ONLY with tables that have a single
> column PK.
>
> If I try to map the Entity Bean with the second
> table, Sun One print that:
> "Table <table name> hasn't got a Primary Key".
>
> To go round the bug, I have to map the Entity Bean
> with the table that doesn't give the problem and
> only after this mapping I can map the second
> bean.
>
> I'll try to use the Capture Schema of Sun One
> Application Server 7, hoping that it runs :-)
>
> Moreno
Hi,
Can anyone help me because I have got the same problem.
"Table does not have the primary key" even though the table has got primary key and I am able to test that at run time successfully.
Whenever I try to map a CMP bean to the table schema the above error is displayed.
Im using oracle8i database and oracle.jdbc.driver.OracleDriver jdbc driver
Thanks in advance,
Krishna
Can you try to capture the schema, this can be done using the Database, schema wizard. Using the file explorer, verify that the captured schema detects what the primary key is.