14

I have an entity/model with discriminator formula and now I'm assigning a discriminator formula like the following sample,

@Entity
@DiscriminatorFormula("type")
class Student {
    // code
}

In the same case, how can I assign discriminator value from application.properties in Spring Boot?

Rohit Suthar
  • 3,528
  • 1
  • 42
  • 48
jeeva
  • 396
  • 6
  • 22

1 Answers1

13

The expression in the class level annotation should be a constant, i.e., final and static. What you are trying to achieve is not possible. The best you can do is read it from a constant file rather than application.properties.

Nick Fortescue
  • 13,530
  • 1
  • 31
  • 37
SakshamB
  • 279
  • 4
  • 13
  • 5
    Basically, you are not correct when saying "is not possible". What @jeeva wants to achieve is possible and doable but requires customising the Hibernates Annotation Binder. It can lead to problems, it is hard to do but possible and doable. – Babl Dec 07 '17 at 16:48