Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Use an entity as a discriminator column

Hi,

I have some entities with an joined inheritance type. In my root entity I have an attribute that is a @ManyToOne relationship to other table. In short, my entity looks like this:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "service")
public class Service implements Serializable {

    @JoinColumn(name = "service_type_id", referencedColumnName = "id")
    @ManyToOne
    private ServiceType serviceTypeId;
   ....

The attribute serviceTypeId is a foreign key to other entity:

@Entity
@Table(name = "service_type")
public class TipoServicio implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;

    @Column(name = "name")
    private String name;
    ......

I'd like to have as DiscriminatorColumn the field serviceTypeId, but I don't know how to do it, as that field hasn't a correct discriminatorType. Is there any way to do what I want?

Thanks!

--
Beatriz Nombela Escobar
beaotx@xxxxxxxxx

Back to the top