Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-dev] @ReturnInsert annotaion on primary key derived out of virtual column

Hi Lukas,...
    I have a virtual column which is very important for our database template and every table who has that virtual column presents problems on generated joins by Named Queries.

The virtual column is part of primary key. However, it's a non insertable and updatable field. I couldn't map the column inside @EmbeddedId on Java entity.


Java entities example.

The virtual column name is DIA_DT_RECIBO.
Its value is defined by another column value named DT_RECIBO. Its default
value is TO_NUMBER(TO_CHAR("DT_RECIBO",'DD')).
The code is outside the PK -> TbReciboNfce.java and TbReciboDetalheNfce.java.
=====

They resolved the issue by adding below code

> On virtual column inside the PK:

ReturnInsert(returnOnly = true)
Column(name = "DIA_DT_RECIBO")
private long diaDtRecibo;

-> On join:

JoinColumn(name = "DIA_DT_RECIBO", referencedColumnName = "DIA_DT_RECIBO",
insertable = false, updatable = false)

Is this a OK solution to use...?  I don't see any issue there, but need confirmation from u too.
Thanks
Ravi


Back to the top