Hello.
I'm trying to persist a record, but when I run it, it is returning the error below:
// ...
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "tipo", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("P")
public class Pessoa {
private Integer id;
private String nome;
}
// ...
@DiscriminatorValue(value = "F")
@PrimaryKeyJoinColumn(name = "id")
public class PessoaFisica extends Pessoa {
private String cpf;
}
@Stateless
public class PessoaFisicaDAO {
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void incluirPessoa(Pessoa pessoa) {
em.persist(pessoa);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="teste">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/testeDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
<!-- <property name="hibernate.hbm2ddl.auto" value="update" /> -->
<!-- <property name="hibernate.show_sql" value="true" /> -->
<!-- <property name="hibernate.format_sql" value="true" /> -->
<!-- <property name="hibernate.generate_statistics" value="true" /> -->
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" />
</properties>
</persistence-unit>
08:17:24,371 INFO [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (default task-10) HHH000397: Using ASTQueryTranslatorFactory
08:17:50,974 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-11) SQL Error: 0, SQLState: 42703
08:17:50,976 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-11) ERROR: column "tipo" of relation "tb_pessoa" does not exist
Posição: 52
Thank you.