Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 177789

Summary: Ability to Specify Attribute Names When Auto-Generating Entity Classes
Product: [WebTools] Dali JPA Tools Reporter: Shelli <shelli.orton>
Component: GeneralAssignee: Neil Hauge <neil.hauge>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: karenfbutzke
Version: 1.0Keywords: helpwanted
Target Milestone: 2.2 M6   
Hardware: PC   
OS: All   
Whiteboard:

Description Shelli CLA 2007-03-16 12:56:19 EDT
When auto-generating entity classes from a database, it would be nice to be able to specify/override the name of the attribute in the entity class.  This would help to avoid situation like this example: 

An entity "Account" has a reference to an "AccountType".  Currently the auto-generation creates the Account class with these attributes:

    @JoinColumn(name = "ACCOUNT_TYPE_ID", referencedColumnName = "ACCOUNT_TYPE_ID")
    @ManyToOne
    private AccountType accountTypeId;

Since "accountTypeId" is actually an instance of AccountType, I would prefer it be named "accountType".  Also, the getter/setter methods:

    public AccountType getAccountTypeId() {
        return this.accountTypeId;
    }

    public void setAccountTypeId(AccountType accountTypeId) {
        this.accountTypeId = accountTypeId;
    }

should be called getAccountType/setAccountType.

Perhaps as part of the "Generate Entities" process, there could be a second step after choosing the tables that lets you pick entities that will be generated and review the default names of the attributes for it.  It would also be good to show what the attribute class is going to be.  If a name is not what the developer would like, at this point the name could be overridden.  If a developer doesn't care, this step can skipped by clicking finish instead of next.

For my example, in the second step when the Account entity is reviewed, it would display the default attribute name "accountTypeId" which would be an instance of the class "AccountType".  Then I would override to then name to "accountType".

See http://www.eclipse.org/newsportal/article.php?id=304&group=eclipse.technology.dali#304 for the news group thread that initiated this request.
Comment 1 Karen Butzke CLA 2009-03-13 11:35:24 EDT
Fixed in 2.2 M6 with the new Entity Generation contribution