Search code examples
spring-data-jdbc

Does Spring Data JDBC support inheritance


I am working on a new project using spring data jdbc because it is very easy to handle and indeed splendid.

In my scenario i have three (maybe more in the future) types of projects. So my domain model could be easily modelled with plain old java objects using type inheritance.

First question:

  • As i am using spring data jdbc, is this way (inheritance) even supported like it is in JPA?

Second question - as addition to the first one:

  • I could not found anything regarding this within the official docs. So i am assuming there are good reasons why it is not supported. Speaking of that, may i be on the wrong track modelling entities with inheritance in general?

Solution

  • Currently Spring Data JDBC does not support inheritance.

    The reason for this is that inheritance make things rather complicated and it was not at all clear what the correct approach is.

    I have a couple of vague ideas how one might create something usable. Different repositories per type is one option, using a single type for persisting, but having some post processing to obtain the correct type upon reading is another one.