emmanuel wrote:
This is the expected behavior.
But a feature request makes sense.
Does Hibernate already have a solution or a workaround for this? I'm running on the same issue.
These are my mappings:
Parent class:Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Pessoa
{
private String matricula;
private String nome;
Pessoa()
{
}
@Id
public String getMatricula()
{
return matricula;
}
public void setMatricula(String matricula)
{
this.matricula = matricula;
}
public String getNome()
{
return nome;
}
public void setNome(String nome)
{
this.nome = nome;
}
}
Subclass:Code:
@Entity
@Table(name = "GE_FUNCIONARIOS")
public class FuncionarioNovo extends Pessoa
{
}
Subclass:Code:
@Entity
@Table(name = "ALUCUR")
@AttributeOverrides({
@AttributeOverride(name = "matricula", column = @Column(name = "CDALUCUR")),
@AttributeOverride(name = "nome", column = @Column(name = "NUGRA"))
})
public class Aluno extends Pessoa
{
}
The generated query:
Code:
select pessoa0_.matricula as matricula0_, pessoa0_.nome as nome0_, pessoa0_.clazz_ as clazz_ from ( select nome, matricula, 1 as clazz_ from GE_FUNCIONARIOS union select nome, matricula, 2 as clazz_ from ALUCUR ) pessoa0_ where pessoa0_.matricula=?
and the error:
Code:
com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'nome'.
Thank you.
Marcos