Skip to main content
2 de 2
adicionou 36 caracteres ao conteúdo
Dherik
  • 11,4mil
  • 2
  • 45
  • 68

Como resolver ERROR: HHH000346: Error during managed flush [org.hibernate.exception.SQLGrammarException: could not execute statement]

Quando tento rodar minha classe de teste me aparece esse erro abaixo. Já não sei mais o que fazer, quando eu comento o atributo FOLDERAUTOUPDATE da classe ApplicationItv funciona a inserção no banco, porém preciso dela.

Alguém pode me ajudar?

INFO: HHH000400: Using dialect: org.hibernate.dialect.OracleDialect
dez 10, 2018 8:35:00 AM org.hibernate.dialect.Oracle9Dialect <init>
WARN: HHH000063: The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead
dez 10, 2018 8:35:00 AM org.hibernate.dialect.OracleDialect <init>
WARN: HHH000064: The OracleDialect dialect has been deprecated; use Oracle8iDialect instead
Hibernate: 
    select
        SEQ_APPLICATION_ITV.nextval 
    from
        dual
Hibernate: 
    insert 
    into
        APPLICATION_ITV
        (bandWidth, folderAutoUpdate, name, who, id) 
    values
        (?, ?, ?, ?, ?)
dez 10, 2018 8:35:01 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 904, SQLState: 42000
dez 10, 2018 8:35:01 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: ORA-00904: "FOLDERAUTOUPDATE": identificador inválido

dez 10, 2018 8:35:01 AM org.hibernate.internal.ExceptionMapperStandardImpl mapManagedFlushFailure
ERROR: HHH000346: Error during managed flush [org.hibernate.exception.SQLGrammarException: could not execute statement]
Falha no banco de dados: 
ORA-00904: "FOLDERAUTOUPDATE": identificador inválido

O banco de dados referente a esta tabela:

CRIAÇÃO DO BANCO DE DADOS

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

O XML de persistência:

<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence 
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

<persistence-unit name="bancoItv">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

    <class>br.com.sky.iTvMC.modelo.ApplicationItv</class> 
    <class>br.com.sky.iTvMC.modelo.AppointmentCategory</class> 
    <class>br.com.sky.iTvMC.modelo.Bit</class> 
    <class>br.com.sky.iTvMC.modelo.Channel</class> 
    <class>br.com.sky.iTvMC.modelo.ChannelCategory</class>
    <class>br.com.sky.iTvMC.modelo.City</class> 
    <class>br.com.sky.iTvMC.modelo.ClientChannel</class> 
    <class>br.com.sky.iTvMC.modelo.ClientChannelAppointment</class> 
    <class>br.com.sky.iTvMC.modelo.Image</class> 
    <class>br.com.sky.iTvMC.modelo.ImageCategory</class>
    <class>br.com.sky.iTvMC.modelo.Segmentation</class> 
    <class>br.com.sky.iTvMC.modelo.SegmentationRules</class> 
    <class>br.com.sky.iTvMC.modelo.Video</class> 
    <class>br.com.sky.iTvMC.modelo.VideoArtist</class> 
    <class>br.com.sky.iTvMC.modelo.VideoCategory</class> 

    <properties>
        <!-- Propriedades JDBC -->
        <property name="javax.persistence.jdbc.driver" 
value="oracle.jdbc.OracleDriver" />
        <property name="javax.persistence.jdbc.url" 
value="jdbc:oracle:thin:@10.16.2.30:1521:apps" />
        <property name="javax.persistence.jdbc.user" value="itv" />
        <property name="javax.persistence.jdbc.password" value="itvsky2015" 
/>
        <!-- Configuracoes especificas do Hibernate -->
        <property name="hibernate.dialect" 
 value="org.hibernate.dialect.OracleDialect" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.format_sql" value="true" />
        <!-- poderia ser: update, create, create-drop, none -->
        <property name="hibernate.hbm2ddl.auto" value="none" />
    </properties>
</persistence-unit>
</persistence>

Meu DAO :

package br.com.sky.iTvMC.dao;

import java.util.List;
import javax.persistence.EntityManager;
import br.com.sky.iTvMC.modelo.ApplicationItv;

public class ApplicationItvDao {

private EntityManager manager;

public ApplicationItvDao(EntityManager manager) {
    this.manager = manager;
}

public void add(ApplicationItv applicationItv) {
    this.manager.persist(applicationItv);
}

public void remove(ApplicationItv applicationItv) {
    this.manager.remove(applicationItv);
}

public void update(ApplicationItv applicationItv) {
    this.manager.merge(applicationItv);
}

public ApplicationItv find(Integer id) {
    return this.manager.find(ApplicationItv.class, id);
}

public List<ApplicationItv> list() {
    return this.manager.createQuery("SELECT * FROM APPLICATION_ITV",     
    ApplicationItv.class).getResultList();
}
}

Minha Classe de teste:

package br.com.sky.iTvMC.teste;
import javax.persistence.EntityManager;
import br.com.sky.iTvMC.dao.ApplicationItvDao;
import br.com.sky.iTvMC.modelo.ApplicationItv;
import br.com.sky.iTvMC.util.*;

public class testandoApplicationItv {

public static void main(String[] args) {
    try {
        EntityManager manager = new JPAUtil().getEntityManager();

        ApplicationItvDao dao = new ApplicationItvDao(manager);
        ApplicationItv applicationItv = new ApplicationItv();
        
        applicationItv.setName("Canal do cliente HD");          
        applicationItv.setBandWidth(230);
        applicationItv.setFolderAutoUpdate("pasta/teste");
        applicationItv.setWho("funcionaroio");          
        
        
        
        manager.getTransaction().begin();
        dao.add(applicationItv);
        manager.getTransaction().commit();
        manager.close();
        System.out.println(applicationItv);
    } catch (Exception e) {
        BDUtil bdUtil = new BDUtil();
        bdUtil.trataSQLException(e);
    }

}

}

Minha Classe Modelo:

package br.com.sky.iTvMC.modelo;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Table(name = "APPLICATION_ITV")
@Entity
public class ApplicationItv {
@SequenceGenerator(name = "seqAppItv", sequenceName = "SEQ_APPLICATION_ITV", 
allocationSize = 1)
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqAppItv")
private Integer id;
private String name;
private Integer bandWidth;
private String folderAutoUpdate;
private String who;

public String getWho() {
    return who;
}

public void setWho(String who) {
    this.who = who;
}

public Integer getId() {
    return id;
}

public void setId(Integer id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public Integer getBandWidth() {
    return bandWidth;
}

public void setBandWidth(Integer bandWidth) {
    this.bandWidth = bandWidth;
}

public String getFolderAutoUpdate() {
    return folderAutoUpdate;
}

public void setFolderAutoUpdate(String folderAutoUpdate) {
    this.folderAutoUpdate = folderAutoUpdate;
}
}