griFlo
griFlo

Reputation: 2164

Map db-functionresult to jpa entity property

I have here a table, where the date is a number. (days since year 0) In the database (oracle) there is a custom function, which converts the number to a date.

Is there an easy way to use that in an jpa Entity?

I just need this for reading. Sure, I could read out the number and convert it myself, but it would be better if i just could use the function.

Something like:

@Entity
public class Person{

@Column(name="toCustomDate(dateAsNumber)")
private Date date;

}

Upvotes: 0

Views: 52

Answers (1)

Dylan Reniers
Dylan Reniers

Reputation: 80

The best shot would be to look into the @Formula annotation, or simply save that date instead of the number in your database?

Upvotes: 2

Related Questions