Re: Use multiple columns for Discriminator in Inheritance Tree with single-table


Yes, JDO, JPA (and Jakarta Persistence) all allow 1 discriminator (value) only. JDO metadata strictly speaking permits multiple columns for some reason, but there is only space for 1 value and that's what DataNucleus has always stuck to. Multiple discriminator values makes little sense to me FWIW.

I don't see any way of having multiple discriminator columns by extending DataNucleus code. The strategy is simply how the value is defined.
A class needs to map to a value, and your system seems to match that basic requirement ... just depends if there are multiple cols in an existing DB. If you can modify the DB to use a single column then you clearly could adapt the value for each class to fit in with JDO / JPA etc

If the table is already existing and you're simply trying to map to it then instead of having a discriminator column (surrogate) you could just add a field directly in your class(es) to map to that column, and thereafter on any queries, restrict that field value. Doesn't really get you to the point of having classes instantiated directly, but at least it models your database data

Join to automatically receive all group messages.