1

hello I have a problem with inheritance in EJB. I show you my code after

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="PROJ_TYPE")
@Table(name="PROJECT")
public abstract class Project {
  @Id
  private long id;
  ...
}

@Entity
@DiscriminatorValue("L");
@Table(name="LARGEPROJECT")
public class LargeProject extends Project {
  private BigDecimal budget;
}

@Entity
@DiscriminatorValue("S");
@Table(name="SMALLPROJECT")
public class SmallProject extends Project {
}

how to get the value of

PROJ_TYPE

. the only solution that I use nativeQuery ,but is there another solution???

sorry for my english and thank you in advance

skaffman
  • 398,947
  • 96
  • 818
  • 769
kohan
  • 11
  • 1
  • 2

1 Answers1

4

It should also be possible to map the discriminator as an additional column, as long as it is not updatable or insertable.

@Column(name="PROJ_TYPE", nullable=false, updatable=false, insertable=false)
private String projectType;
Jörn Horstmann
  • 33,639
  • 11
  • 75
  • 118
  • Ok thanks I will try this my problem was how to get value of PROJ_TYPE from datbase because i don’t have a get for PROJ_TYPE in entity – kohan Nov 20 '10 at 23:28