I have this class
@Entity
@Table(name = "DB.APPL_SESSION")
@AttributeOverrides({@AttributeOverride(name = "id", column = @Column(name = "APPL_SESSION_ID"))})
@SequenceGenerator(name = "TableSequence", sequenceName = "DB.APPL_SESSION_SQ")
public class AiSession{
@Formula("(select sum(nvl(budg.AMT_OV,budg.AMT)) from DB.BUDGET budg where budg.APPL_SESSION_ID = APPL_SESSION_ID)")
private LocalDate realSessionStartDate;
In the above formula I was working with DB.BUDGET object and with the current object id ( APPL_SESSION_ID). But now I wanted only to work with the next member variable (StartDate) which is in AidApplicantYearSession class
@Basic
@Temporal(TemporalType.DATE)
@Column(name = "START_OV_DT")
private Date overrideStartDate;
How should I write a formula that looks like the above on but uses only the object's member variable ? I came up with
@Formula("(select START_OV_DT from DB.APPL_SESSION)")
Is that the correct way? The logic for the two formulas is totaly different.
@Formula
is simply inserted into the SQL select
clause, so that you can use column names in it:
@Formula("START_OV_DT")
See also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With