JPA / EclipseLink - calculated column

I am trying to learn JPA. I created a simple entity class. This object has 3 columns: ID, NAME, NUMBER_A. It works great: I can save, update and delete without problems.

What I'm trying to do is create a calculated / computed column. I want to get NUMBER_A, use it to compute a new value and set the computed column (say, CALC_COLUMN).

This calculated column will not be saved. This is only necessary at runtime.

I tried to create a simple double object and its getter and setter, but when I run the application, it gives an error message indicating that the CALC_COLUMN column does not exist because JPA / EclipseLink is trying to use it as a valid database column (Column "CALC_COLUMN" either not in any table in the FROM list ...).

So can this be done?

TIA, Bob

+3
source share
1 answer

What I'm trying to do is create a calculated / computed column.

JPA . , Hibernate @Formula, EclipseLink ( , . ).

. .

?:)

getter setter, , , , CALC_COLUMN , JPA/EclipseLink ( "CALC_COLUMN" FROM...).

, - , getter ( - ), . @Transient. , , . ( ).

+2

Source: https://habr.com/ru/post/1767616/


All Articles