Herança Hibernate

0 respostas
D

Pessoal estou com um problema na herança com hibernate.

Tenho a Classe Base
Tenho a Classe Pessoa herda Base
Tenho a Classe Cliente herda Pessoa

@MappedSuperclass
public abstract class Base implements IBase, Serializable {
@Entity
@Table(name = "PESSOA")
@Inheritance(strategy = InheritanceType.JOINED)

public abstract class Pessoa extends Base implements Serializable {

    private Long aCdPessoa;

        @Id
	@Column(name = "CODIGO_PESSOA", nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_PES")
	@SequenceGenerator(name = "SEQ_PES", sequenceName = "GEN_PESSOA")
	public Long getCdPessoa() {
		return this.aCdPessoa;
	}
...
@Entity
@Table(name = "CLIENTE")
@PrimaryKeyJoinColumn(name = "CODIGO_PESSOA")
public class Cliente extends Pessoa implements Serializable {
    
     	private String aNuReferencia;

	@Column(name = "NU_REFERENCIA", nullable = false, length = 20)
	@Length(max = 20)
	public String getNuReferencia() {
		return this.aNuReferencia;
	}

...

Com este mapeamento o hibernate está gerando a tabela “CLIENTE” colocando o “CODIGO_PESSOA” como chave primária, mais eu gostaria que na tabela cliente a chave primária fosse “NU_REFERENCIA” e “CODIGO_PESSOA” ficasse apenas como FK.

Alguém poderia ajudar?

Valeu!!!

Criado 22 de março de 2007
Respostas 0
Participantes 1