I have a legacy MS SQL Server 2000 datatabase I am trying to map with JPA (EclipseLink to be precise).
I have a table "CONTACT1" with a text field "KEY1" which can be either 'Contact' or 'Asset', and I am using:
@Table(name = "CONTACT1")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "KEY1")
public abstract class Record {
to map it to two different classes (Contact and Asset).
@Entity
@DiscriminatorValue(value = "Contact")
public class Contact extends Record {...}
and
@Entity
@DiscriminatorValue(value = "Asset")
public class Asset extends Record {...}
Unfortunately I found out some or the records are missing, and after further analysis I realised some contact records have the "KEY1" field set to NULL.
While I could just run an update query to fix the problem I would like to avoid that - is there a way to map that 'NULL' value to a Contact class?
Failing that, is there a mechanism in JPA where I can pre-filter the recordsets making JPA believe that field is not NULL but it has 'Contact' written in it?