Cornel B
Cornel B

Reputation: 539

Hibernate & Java - mapping similar cols

How would I map elegantly a table that has let's say 15 similar columns like:

NOTE1_TXT    VARCHAR2(80)  
NOTE2_TXT    VARCHAR2(80)   
NOTE3_TXT    VARCHAR2(80)

etc

NOTE15_TXT   VARCHAR2(80)

The db structure cant be changed.

I really hate having to add 15 fields with getter/setter methods:

@Column(name = "NOTE1_TXT")
private String claimNoteText1;

Tks,

Upvotes: 2

Views: 72

Answers (1)

2020
2020

Reputation: 2841

If your entity class members can have the same name as the database fields, then there is no need for the "@Column" annotations. And the IDEs can generate the getters/setters for you (for ex: Eclipse has a "Source" menu with a "Generate Getters and Setters" option).

Upvotes: 2

Related Questions