This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 56333 - Primary key is lost in dbschema (PostgreSQL, MySQL)
Summary: Primary key is lost in dbschema (PostgreSQL, MySQL)
Status: CLOSED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: DB schema (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: Radko Najman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-13 11:35 UTC by tkrivanek
Modified: 2006-03-24 13:09 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Generated schema using older driver - OK (16.72 KB, text/xml)
2005-03-13 11:36 UTC, tkrivanek
Details
Generated schema using newer driver - Bad, without PK (13.50 KB, text/xml)
2005-03-13 11:37 UTC, tkrivanek
Details
Runtime tab screenshot (31.65 KB, image/png)
2005-03-14 21:17 UTC, tkrivanek
Details
Database schema screenshot (29.29 KB, image/png)
2005-03-14 21:18 UTC, tkrivanek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tkrivanek 2005-03-13 11:35:10 UTC
Hallo,
I am using NetBeans 4.1beta + AS bundle. Creating CMP EJB from existing databse
is very difficult due to problems described below.

Primary key is lost in generated dbschema. At first i think this is a JDBC
driver issue, but then i discovered that this feature is working for older
version of JDBC drivers only. When i use pg72jdbc2.jar or
mysql-connector-java-3.0.16-ga-bin.jar, everything works but when i use later
drivers like mysql-connector-java-3.1.7-bin.jar,
mysql-connector-java-3.2.0-alpha-bin.jar, pg73jdbc2.jar, pg74.215.jdbc2.jar or
postgresql-8.0-310.jdbc2.jar generated dbschema does not contain information
about PKs.
This is my test db: 

CREATE TABLE test (id int4, name varchar(16), primary key(id));

Schema files generated using pg72jdbc2.jar and pg73jdbc2.jar are in attechement.

You can quickly check if this problem persists. When you check databse in
explorer window in Runtime tab, you will see Index test_pkey with "Non-unique"
property set to false (which is right). But when you generate schema for this
table, you will see "Unique" property of test_pkey index set to false (which is
wrong).
Comment 1 tkrivanek 2005-03-13 11:36:55 UTC
Created attachment 20805 [details]
Generated schema using older driver - OK
Comment 2 tkrivanek 2005-03-13 11:37:37 UTC
Created attachment 20806 [details]
Generated schema using newer driver - Bad, without PK
Comment 3 Petr Jiricka 2005-03-14 14:18:16 UTC
Can you please check whether the primary key is detected correctly when you
browse the database using the database explorer in Runtime tab? Thanks.
Comment 4 tkrivanek 2005-03-14 21:16:07 UTC
Yes, it is detected correctly in explorer regardless of JDBC driver version.
Here are screenshots where you can see how it looks with pg73jdbc2.jar in
explorer and in dbschema (PK and UNIQUE flag are lost).
Comment 5 tkrivanek 2005-03-14 21:17:21 UTC
Created attachment 20828 [details]
Runtime tab screenshot
Comment 6 tkrivanek 2005-03-14 21:18:35 UTC
Created attachment 20829 [details]
Database schema screenshot
Comment 7 Radko Najman 2005-03-16 16:15:59 UTC
It should work now for all PostgreSQL drivers. It was caused by a change in the
recent driver implementations - getIndexInfo() method now returns "f" value for
NON_UNIQUE column.

Unable to fix it for MySQL. In this case it is a driver bug.
mysql-connector-java-3.0.16-ga-bin.jar returns "false" for getIndexInfo()
NON_UNIQUE column, but mysql-connector-java-3.2.0-alpha-bin.jar returns "true".

Comment 8 Lukasz Grela 2006-01-16 12:48:47 UTC
this issue will be marked as verified because it's quite old