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.
Summary: | Perstitence class generation does not recognize automatically generated columns | ||
---|---|---|---|
Product: | javaee | Reporter: | jfurmankiewicz <jfurmankiewicz> |
Component: | Persistence | Assignee: | Andrei Badea <abadea> |
Status: | RESOLVED DUPLICATE | ||
Severity: | blocker | CC: | abadea, gsporar, pjiricka |
Priority: | P3 | ||
Version: | 5.x | ||
Hardware: | All | ||
OS: | Windows XP | ||
Issue Type: | ENHANCEMENT | Exception Reporter: | |
Attachments: | Sequence samples |
Description
jfurmankiewicz
2006-10-12 19:30:10 UTC
changing priority to P3 because PostgreSQL is not supported database. Generated column values aren't supported for any database, since there is almost no support for it in JDBC. How could one infer the "entity_entity_id_seq" sequence name? Is it always the table name, column name and "seq" concatenated and separated by underscores (when the column type is serial/bigserial)? Or is there a way to query the PostgreSQL JDBC driver for the sequence name? Honestly, I am not sure. I understand though that PostgreSql automatically creates a sequence for you when defining a "serial" column, using the format: (table_name)_(column_name)_seq so, for "entity.entity_id" we would get a sequence called "entity_entity_id_seq". I am not sure if you can get this via JDBC or not. If at the very least NB could generated the @GeneratedValue annotation using this strategy, we would probably cover 99% of the use cases for PostgreSQL. See attached screenshot. Created attachment 38553 [details]
Sequence samples
*** Issue 114315 has been marked as a duplicate of this issue. *** *** Issue 118275 has been marked as a duplicate of this issue. *** *** Issue 121407 has been marked as a duplicate of this issue. *** Changing to enhancement. I know this is dissapointing, but supporting generated columns was never in the scope of the Entity Classes from DB wizard when it was introduced in 5.0. The needed infrastructure is missing from the database support, so there is also no point in pretending that this can be fixed for 6.1. Sorry to hear that. This would be very useful if we have to generate entity classes for let's say 200 tables in one shot. Without support for this we would need to open 200 Java classes by hand after they were generated and modify them manually. Maybe a good solution would be for the wizard to prompt for an optional sequence format (e.g. "<TABLE_NAME>_SEQ") that would be autogenerated when creating entity classes ... most DBs have some common naming schema they follow for sequence names. This would probably be fairly simple, would not entail any major changes to the DB support (since you are relying on the programmer to tell you what the sequence naming schema should be instead of trying to figure it out yourself). Closing this as a duplicate of issue 76357. Although this issue has many duplicates, I prefer to leave 76357 open in order to avoid losing its votes. jfurmankiewicz: that would be quite a crude hack, and a PostgreSQL-oriented one. MySQL and MSSQL Server have identity columns instead of sequences. *** This issue has been marked as a duplicate of 76357 *** |