I’m trying to know if the following example works with @Formula
of hibernate, perhaps someone can help to solve the other ways, to use sql or queries.
@Formula("SELECT( NOW() > column_date - interval '1 minute' * column_a )") private Boolean columnA;
When I do that example get the following error:
2019-03-03 05:29:57.568 ERROR [service_a,4fedd46e4085e86f,4fedd46e4085e86f,false] 608 — [nio-8090-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: schema “table_a0_” does not exist Position: 5560
2019-03-03 05:29:57.581 INFO [service_a,4fedd46e4085e86f,4fedd46e4085e86f,false] 608 — [nio-8090-exec-1] o.h.e.internal.DefaultLoadEventListener : HHH000327: Error performing load command :
what is it wrong on my sql expression?
Advertisement
Answer
There should be a proper SQL query in @Formula
, something like:
@Formula("select NOW() > ( column_date + interval '1 minute' * column_a ) from some_table")
Of course assuming your dbms reads this syntax. some_table
is a table, where column_date
and column_a
are.
The easiest would be to run SQL queries against your database and insert it into @Formula
when successful.