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 129870 - Entity Classes from Database does not generate @GeneratedValue
Summary: Entity Classes from Database does not generate @GeneratedValue
Status: RESOLVED DUPLICATE of bug 76357
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Martin Adamek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-12 09:22 UTC by Matthew Bohm
Modified: 2008-03-12 19:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Bohm 2008-03-12 09:22:33 UTC
- Set up MySQL.
- Set up the Sakila database (http://dev.mysql.com/doc/#sampledb)
- Run the Entity Classes from Database wizard on all tables except film_text, creating a persistence unit with "None"
for the table generation strategy. (You can put the generated entities in a package called "sakila".)
- Take a look at Film.java, for instance. The id field is:

    @Id
    @Column(name = "film_id", nullable = false)
    private Short filmId;

Notice there is nothing like @GeneratedValue(strategy = GenerationType.AUTO). I'm not sure this is correct, given that
the column is auto-increment:

CREATE TABLE film (
  film_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
...

Can this be addressed for 6.1? This issue affects the JSF Pages from Entity Class wizard.
Comment 1 Andrei Badea 2008-03-12 11:30:38 UTC
Sorry, there is no way to fix this for 6.1.


*** This issue has been marked as a duplicate of 76357 ***
Comment 2 Matthew Bohm 2008-03-12 19:00:16 UTC
I do not understand why this would be a difficult fix. Can't the IDE invoke java.sqlDatabaseMetaData.getColumns and look
at the IS_AUTOINCREMENT value?
Comment 3 Andrei Badea 2008-03-12 19:14:09 UTC
Not for 6.1 for a couple of reasons:

- IS_AUTOINCREMENTED was added in JDBC 4. Older drivers won't support it, and even JDBC 4 drivers would need to be
tested. This should be done at the beginning of the release, not at the end.
- the entity class generator doesn't use the DMD directly. There is a database model layer in the middle that would need
to be updated too.
Comment 4 Andrei Badea 2008-03-12 19:24:18 UTC
For the record, though, the MySQL Connector/J driver does seem to support IS_AUTOINCREMENT.