5

I would like to know if we can set the custom parameter in @Formula through the application.

@Formula(TAX_RATE * price)
private Integer totalPrice;

TAX_RATE is NOT a column in database, where as 'price' is the column in db.

How can I set the TAX_RATE value during the runtime of the query through the application?

Somebody suggested to use Hibernate Interceptor 'onPreparedStatement' method. Is there any better way ?

Srinivas Lakshman
  • 469
  • 2
  • 4
  • 21
  • You can't. If it's not a database column what is the point anyway. What problem are you trying to solve? – Alan Hay Feb 19 '20 at 18:21
  • Hi Alan, thank you for the reply. It's an API where customers in different countries use this. So, the front end application gets the TAX_RATE from another application and passes it into my application. So, to dynamically adjust the totalPrice, we are trying to use it in formula. – Srinivas Lakshman Feb 19 '20 at 22:15
  • Ok. Ask a question about the actual problem and how you might be able to solve it. – Alan Hay Feb 19 '20 at 22:44
  • Have you solved this problem? – xc93hil Oct 31 '20 at 13:24
  • I think this link https://stackoverflow.com/questions/25283767/how-to-use-spring-managed-hibernate-interceptors-in-spring-boot will help you – Andrew Niken Feb 06 '21 at 18:01

0 Answers0