I'm trying to map a legacy database, and I'd like to use a combination of two date fields of which the first (date_col) contains the date of interest and the second (time_col) contains the time of day.
I mapped the column with
Code:
@Formula("(trunc(date_col) - trunc(time_col) + time_col)")
private Date departure;
... which is all well, but what I'm also looking for is a @JoinFormula to use above property as a foreign key.
Code:
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumns(value={
@JoinColumn(name="areaid",referencedColumnName="areaid"),
@JoinFormula(expression="(trunc(date_col) - trunc(time_col) + time_col)", referencedColumnName=departure_timestamp)
})
private DeparturePriority prio;
Is there a way to emulate this? I'm perfectly OK with some SQL here.
thanks in advance
Thomas.