wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Conventions for name of ID-Field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Conventions for name of ID-Field" Watch "Conventions for name of ID-Field" New topic
Author

Conventions for name of ID-Field

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
When using this:

@Id
private Integer idPk;

then the field name "IDPK" is generated instead of "ID_PK"


So I have to use this:

@Id @Column(name = "ID_PK")
private Integer idPk;

to generate the fieldname "ID_PK".


I have thought, the conventions for defining the ID name is using the id with underscore continued with the first upper case of the property name. JPA should use this convention. Am I right?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What makes you think that is, or should be, the convention? I think "id" should come at the end--makes a lot more sense to me.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

I agree with David, while an underscore separator may be a convention it is not a standard. Some databases will treat an underscore as a wildcard character for white space so it can be problematic to use.

Also, personally, I think ID_PK is tautologous anyway. PK == ID, do why not name your identifying attribute "ID"?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
Hello both,

why not name your identifying attribute "ID"



This is a good suggestion. I renamed it.

Thanks.



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conventions for name of ID-Field