I'm using Hibernate through JPA interface (EntityManager), and would appreciate it if anyone could help with the following question:
What is the recommended way to define a conversion rule between my database data, and my Java data ?
For example, say my (badly designed) database stores string values of "YES" and "NO", which I'd like to convert to java boolean :
Code:
Table "SUBSCRIPTION":
---------------------------------
| ID | IS_MONTHLY
---------------------------------
| 1 | 'YES'
| 2 | 'NO'
| 3 | 'NO'
---------------------------------
Java class:
@Entity public class Subscription {
@Id private long id;
private boolean isMonthly; // boolean
...
}
What is the recommended way to do the conversion ?
Thanks:)