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 164783 - Name convertion mechanism for "entity from database" wizard
Summary: Name convertion mechanism for "entity from database" wizard
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@javaee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-08 16:27 UTC by mvtomilov
Modified: 2016-07-07 08:56 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
patch (127.26 KB, text/plain)
2009-05-08 16:29 UTC, mvtomilov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mvtomilov 2009-05-08 16:27:47 UTC
Hello. I've added a feature to NetBeans "Entity from database" wizard. There was no ability to affect name convertion
mechanism of that wizard, but in some cases it may be useful. For example, if I have a database with the following tables:

CREATE TABLE `Student` (
  `idStudent` int(11) NOT NULL auto_increment,
  `name` varchar(255) default NULL,
  `idTeacher` int(11) default NULL,
  PRIMARY KEY  (`idStudent`),
  KEY `FKF3371A1B172E44FC` (`idTeacher`),
  CONSTRAINT `FKF3371A1B172E44FC` FOREIGN KEY (`idTeacher`) REFERENCES `Teacher` (`idTeacher`)
);

CREATE TABLE `Teacher` (
  `idTeacher` int(11) NOT NULL auto_increment,
  `name` varchar(64) NOT NULL,
  PRIMARY KEY  (`idTeacher`)
);

then standard "Entity from database" wizard generates field idTeacher in Student class for that database. This field
looks like an identifier but as a matter of fact it has a Teacher type. So, using prefix "id" for the name of that field
may confuse a programmer.

My patch provides an ability to affect name convertion mechanism for primary keys, foreign keys and foreign key
referenced fields.

Below is the detailed description of my feature I have written for NetBeans help:
You may use regular expressions for converting and/or manual convertion (to adjust automatic name convertion for
example). Regular expressions are applied separately for different field types. You may store your regular expression
patterns using Add button (optional).

You may use the following keywords in target expressions:

   1. %>ENTITY% or %<ENTITY% is a name of a class which corresponding current field. If second charater is '>' then
replacement begins with capital letter, if it is '<', then replacement begins with lower-case letter.
   2. %>REFENTITY% or %<REFENTITY% can be used for foreign key and field corresponding to foreign key only. The
replacement for this keyword is the referenced entity name.

Also, you can use Java regular expression groups capturing mechanism. But with a little difference. You must use '>' or
'<' symbol to indicate whether the first letter should be upper-case or lower-case. For example, $<1 is a first group
but with decapitalized first letter.
Comment 1 mvtomilov 2009-05-08 16:29:31 UTC
Created attachment 81819 [details]
patch
Comment 2 Sergey Petrov 2012-02-09 18:56:25 UTC
there is no advanced features like suggested so far, but there is an option for a few releases 'Use Column Names in relationships' and relationsship member may be generated two ways:
    private MicroMarket microMarket;;
or
    private MicroMarket zip; //where zip is id member of MicroMarket
Comment 3 Martin Balin 2016-07-07 08:56:08 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss