Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » Attribute Names in Generated EJB
Attribute Names in Generated EJB [message #434347] Thu, 15 March 2007 16:57 Go to next message
Shelli is currently offline ShelliFriend
Messages: 6
Registered: July 2009
Junior Member
Hi,

I'm just learning about EJB3 and have downloaded Eclipse v. 3.3.0 with the
latest WTP plugin. I really like the feature to auto-generate EJB entity
classes from a database. However, I have a concern with how some of the
attributes were named. For example, I have a entity "Account" which
references an "AccountType". It's defined like this in the Account class:

@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. Other than manually
changing this, is there anything I can do to make this happen when the
class is generated? Since I have 41 entity classes that have been
auto-generated, updating them manually would be very labour intensive.

Thanks in advance!
Re: Attribute Names in Generated EJB [message #434349 is a reply to message #434347] Fri, 16 March 2007 14:51 Go to previous messageGo to next message
Brian Vosburgh is currently offline Brian VosburghFriend
Messages: 137
Registered: July 2009
Senior Member
Hello, Shelli.

Right now, the easiest way to force Dali to give you more reasonable
attribute names is to use table and column names that allow Dali to take
advantage of the JPA spec defaults. So, in your example:

- the "foreign" table's primary key name would be changed to simply ID
- the foreign key column name would be unchanged, ACCOUNT_TYPE_ID

This should result in a field like this:

@ManyToOne
private AccountType accountType;

Along with simplifying your mapping annotations, this allows you to have
multiple ManyToOne (or OneToOne) mappings to the same table and some
semblance of reasonablly semantic names. For example, you could have two
foreign keys, ACCOUNT_TYPE_ID and SPECIAL_ACCOUNT_TYPE_ID, on the same
table and, as long as the primary key field on the "foreign" table is
named ID, you would end up with two appropriately-named attributes,
accountType and specialAccountType.

Brian Vosburgh


Shelli wrote:
> Hi,
>
> I'm just learning about EJB3 and have downloaded Eclipse v. 3.3.0 with
> the latest WTP plugin. I really like the feature to auto-generate EJB
> entity classes from a database. However, I have a concern with how some
> of the attributes were named. For example, I have a entity "Account"
> which references an "AccountType". It's defined like this in the
> Account class:
>
> @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. Other than manually
> changing this, is there anything I can do to make this happen when the
> class is generated? Since I have 41 entity classes that have been
> auto-generated, updating them manually would be very labour intensive.
>
> Thanks in advance!
>
>
Re: Attribute Names in Generated EJB [message #434351 is a reply to message #434349] Fri, 16 March 2007 15:14 Go to previous messageGo to next message
Shelli is currently offline ShelliFriend
Messages: 6
Registered: July 2009
Junior Member
Hi Brian,

Thanks for responding. So, are you saying that I need to change the
column names in the database schema itself? I'm afraid that isn't an
option for me as the database is not new. We are looking at creating a
new web app that uses the database and are exploring the EJB3/JSF option.

Thanks again,
Shelli

Brian Vosburgh wrote:

> Hello, Shelli.

> Right now, the easiest way to force Dali to give you more reasonable
> attribute names is to use table and column names that allow Dali to take
> advantage of the JPA spec defaults. So, in your example:

> - the "foreign" table's primary key name would be changed to simply ID
> - the foreign key column name would be unchanged, ACCOUNT_TYPE_ID

> This should result in a field like this:

> @ManyToOne
> private AccountType accountType;

> Along with simplifying your mapping annotations, this allows you to have
> multiple ManyToOne (or OneToOne) mappings to the same table and some
> semblance of reasonablly semantic names. For example, you could have two
> foreign keys, ACCOUNT_TYPE_ID and SPECIAL_ACCOUNT_TYPE_ID, on the same
> table and, as long as the primary key field on the "foreign" table is
> named ID, you would end up with two appropriately-named attributes,
> accountType and specialAccountType.

> Brian Vosburgh
Re: Attribute Names in Generated EJB [message #434353 is a reply to message #434351] Fri, 16 March 2007 16:13 Go to previous message
Brian Vosburgh is currently offline Brian VosburghFriend
Messages: 137
Registered: July 2009
Senior Member
To answer your question: Yes, I am saying to change the column names;
but it sounds like that is not something you can do.

The sort of feature you describe in your first message should probably
be configurable as a user setting or preference. At the moment, Dali is
focused on supporting the creation and maintenance of mappings between
existing Entities and database tables. No matter what sort of entities are
generated by any tool, you will need to review and modify them. Hopefully,
Dali will provide excellent support for that.

You should enter a description of what you want as an Enhancement Request
on Bugzilla; and, if you are feeling really energetic :-), submit a
corresponding patch.

Thanks.
Brian Vosburgh

Shelli wrote:
> Hi Brian,
>
> Thanks for responding. So, are you saying that I need to change the
> column names in the database schema itself? I'm afraid that isn't an
> option for me as the database is not new. We are looking at creating a
> new web app that uses the database and are exploring the EJB3/JSF option.
>
> Thanks again,
> Shelli
>
> Brian Vosburgh wrote:
>
>> Hello, Shelli.
>
>> Right now, the easiest way to force Dali to give you more reasonable
>> attribute names is to use table and column names that allow Dali to take
>> advantage of the JPA spec defaults. So, in your example:
>
>> - the "foreign" table's primary key name would be changed to
>> simply ID
>> - the foreign key column name would be unchanged, ACCOUNT_TYPE_ID
>
>> This should result in a field like this:
>
>> @ManyToOne
>> private AccountType accountType;
>
>> Along with simplifying your mapping annotations, this allows you to have
>> multiple ManyToOne (or OneToOne) mappings to the same table and some
>> semblance of reasonablly semantic names. For example, you could have two
>> foreign keys, ACCOUNT_TYPE_ID and SPECIAL_ACCOUNT_TYPE_ID, on the same
>> table and, as long as the primary key field on the "foreign" table is
>> named ID, you would end up with two appropriately-named attributes,
>> accountType and specialAccountType.
>
>> Brian Vosburgh
>
>
Re: Attribute Names in Generated EJB [message #593291 is a reply to message #434347] Fri, 16 March 2007 14:51 Go to previous message
Brian Vosburgh is currently offline Brian VosburghFriend
Messages: 137
Registered: July 2009
Senior Member
Hello, Shelli.

Right now, the easiest way to force Dali to give you more reasonable
attribute names is to use table and column names that allow Dali to take
advantage of the JPA spec defaults. So, in your example:

- the "foreign" table's primary key name would be changed to simply ID
- the foreign key column name would be unchanged, ACCOUNT_TYPE_ID

This should result in a field like this:

@ManyToOne
private AccountType accountType;

Along with simplifying your mapping annotations, this allows you to have
multiple ManyToOne (or OneToOne) mappings to the same table and some
semblance of reasonablly semantic names. For example, you could have two
foreign keys, ACCOUNT_TYPE_ID and SPECIAL_ACCOUNT_TYPE_ID, on the same
table and, as long as the primary key field on the "foreign" table is
named ID, you would end up with two appropriately-named attributes,
accountType and specialAccountType.

Brian Vosburgh


Shelli wrote:
> Hi,
>
> I'm just learning about EJB3 and have downloaded Eclipse v. 3.3.0 with
> the latest WTP plugin. I really like the feature to auto-generate EJB
> entity classes from a database. However, I have a concern with how some
> of the attributes were named. For example, I have a entity "Account"
> which references an "AccountType". It's defined like this in the
> Account class:
>
> @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. Other than manually
> changing this, is there anything I can do to make this happen when the
> class is generated? Since I have 41 entity classes that have been
> auto-generated, updating them manually would be very labour intensive.
>
> Thanks in advance!
>
>
Re: Attribute Names in Generated EJB [message #593303 is a reply to message #434349] Fri, 16 March 2007 15:14 Go to previous message
Shelli is currently offline ShelliFriend
Messages: 6
Registered: July 2009
Junior Member
Hi Brian,

Thanks for responding. So, are you saying that I need to change the
column names in the database schema itself? I'm afraid that isn't an
option for me as the database is not new. We are looking at creating a
new web app that uses the database and are exploring the EJB3/JSF option.

Thanks again,
Shelli

Brian Vosburgh wrote:

> Hello, Shelli.

> Right now, the easiest way to force Dali to give you more reasonable
> attribute names is to use table and column names that allow Dali to take
> advantage of the JPA spec defaults. So, in your example:

> - the "foreign" table's primary key name would be changed to simply ID
> - the foreign key column name would be unchanged, ACCOUNT_TYPE_ID

> This should result in a field like this:

> @ManyToOne
> private AccountType accountType;

> Along with simplifying your mapping annotations, this allows you to have
> multiple ManyToOne (or OneToOne) mappings to the same table and some
> semblance of reasonablly semantic names. For example, you could have two
> foreign keys, ACCOUNT_TYPE_ID and SPECIAL_ACCOUNT_TYPE_ID, on the same
> table and, as long as the primary key field on the "foreign" table is
> named ID, you would end up with two appropriately-named attributes,
> accountType and specialAccountType.

> Brian Vosburgh
Re: Attribute Names in Generated EJB [message #593319 is a reply to message #434351] Fri, 16 March 2007 16:13 Go to previous message
Brian Vosburgh is currently offline Brian VosburghFriend
Messages: 137
Registered: July 2009
Senior Member
To answer your question: Yes, I am saying to change the column names;
but it sounds like that is not something you can do.

The sort of feature you describe in your first message should probably
be configurable as a user setting or preference. At the moment, Dali is
focused on supporting the creation and maintenance of mappings between
existing Entities and database tables. No matter what sort of entities are
generated by any tool, you will need to review and modify them. Hopefully,
Dali will provide excellent support for that.

You should enter a description of what you want as an Enhancement Request
on Bugzilla; and, if you are feeling really energetic :-), submit a
corresponding patch.

Thanks.
Brian Vosburgh

Shelli wrote:
> Hi Brian,
>
> Thanks for responding. So, are you saying that I need to change the
> column names in the database schema itself? I'm afraid that isn't an
> option for me as the database is not new. We are looking at creating a
> new web app that uses the database and are exploring the EJB3/JSF option.
>
> Thanks again,
> Shelli
>
> Brian Vosburgh wrote:
>
>> Hello, Shelli.
>
>> Right now, the easiest way to force Dali to give you more reasonable
>> attribute names is to use table and column names that allow Dali to take
>> advantage of the JPA spec defaults. So, in your example:
>
>> - the "foreign" table's primary key name would be changed to
>> simply ID
>> - the foreign key column name would be unchanged, ACCOUNT_TYPE_ID
>
>> This should result in a field like this:
>
>> @ManyToOne
>> private AccountType accountType;
>
>> Along with simplifying your mapping annotations, this allows you to have
>> multiple ManyToOne (or OneToOne) mappings to the same table and some
>> semblance of reasonablly semantic names. For example, you could have two
>> foreign keys, ACCOUNT_TYPE_ID and SPECIAL_ACCOUNT_TYPE_ID, on the same
>> table and, as long as the primary key field on the "foreign" table is
>> named ID, you would end up with two appropriately-named attributes,
>> accountType and specialAccountType.
>
>> Brian Vosburgh
>
>
Previous Topic:UML class diagrams of JPA models
Next Topic:Dali Installation
Goto Forum:
  


Current Time: Wed Apr 24 23:06:22 GMT 2024

Powered by FUDForum. Page generated in 0.03241 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top