-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: SQLGrammarException???
PostPosted: Fri Jun 23, 2006 4:35 pm 
Newbie

Joined: Fri Jun 23, 2006 3:52 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi I'm brazilian and need help someone, because in Brazil foruns don't get
us to decide this wrong.

Forgive for my english.

Hibernate.cfg.xml:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://localhost:8084/LeituraWeb/hibernate-configuration-3_0_dtd.dtd">

<hibernate-configuration>
<session-factory>

<!-- Parâmetros de conexão ao banco de dados -->
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost/LeituraBD?charSet=ASCII</property>
<property name="connection.username">postgres</property>
<property name="connection.password">vector</property>

<!-- Dialeto SQL do banco -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

<!-- Exibe comandos SQL na saída padrão -->
<property name="show_sql">true</property>

<!-- Arquivos de mapeamento OO/Relacional -->

<mapping resource="br/com/leitura/core/Fornecedor.hbm.xml"/>
<mapping resource="br/com/leitura/core/Bairro.hbm.xml"/>
<mapping resource="br/com/leitura/core/Cidade.hbm.xml"/>
</session-factory>
</hibernate-configuration>


fornecedor.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://localhost:8084/LeituraWeb/hibernate-mapping-3_0_dtd.dtd">
<!--
Document : Grupo.xml
Created on : 25 de Maio de 2006, 10:42
Author : Genuino Teixeira
Description:
Purpose of the document follows.
-->

<hibernate-mapping>
<class name="br.com.leitura.core.Fornecedor" table="tbl_fornecedor">
<id name="codFornecedor" >
<column name="CNPJ" length="30" not-null="true"/>
<generator class="assigned"/>
</id>
<property name="nome">
<column name="NOME" not-null="true"/>
</property>
<property name="numero">
<column name="NUMERO" not-null="true"/>
</property>
<property name="complemento">
<column name="COMPLEMENTO"/>
</property>
<property name="email">
<column name="E_MAIL" not-null="true"/>
</property>
<property name="contato">
<column name="CONTATO" not-null="true"/>
</property>
<property name="descontos" type="java.lang.Double">
<column name="descontos" not-null="true"/>
</property>
<property name="dataAtualizacao">
<column name="DATA_ATUALIZACAO" not-null="true"/>
</property>
<property name="horaAtualizacao">
<column name="HORA_ATUALIZACAO" not-null="true"/>
</property>
<property name="dataCadastro">
<column name="DATA_CADASTRO" not-null="true"/>
</property>
<many-to-one name="cidade" column="COD_CIDADE"
class="br.com.leitura.core.Cidades" cascade="all"/>
<many-to-one name="bairro" column="COD_BAIRRO"
class="br.com.leitura.core.Bairro" cascade="save-update"/>
<set name="telefones" table="tbl_tel_fornecedor" cascade="all">
<key column="cod_fornecedor"/>
<element column="telefone" type="string"/>
</set>
</class>
</hibernate-mapping>


cidade.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://localhost:8084/LeituraWeb/hibernate-mapping-3_0_dtd.dtd">
<!--
Document : Grupo.xml
Created on : 25 de Maio de 2006, 10:42
Author : Genuino Teixeira
Description:
Purpose of the document follows.
-->

<hibernate-mapping>
<class name="br.com.leitura.core.Cidades" table="tbl_cidades">
<id name="codigo" column="CODIGO">
<generator class="sequence">
<param name="sequence">tbl_cidades_codigo_seq</param>
</generator>
</id>
<property name="cidade">
<column name="CIDADE" not-null="true"/>
</property>
<property name="estado">
<column name="ESTADO" not-null="true"/>
</property>
<property name="pais">
<column name="PAIS" not-null="true"/>
</property>
<property name="prazoEntrega">
<column name="PRAZO_ENTREGA" not-null="true"/>
</property>
<set name="fornecedores" lazy="true" inverse="true" cascade="all">
<key column="cod_cidade"/>
<one-to-many class="br.com.leitura.core.Fornecedor"/>
</set>
</class>
</hibernate-mapping>

bairro:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://localhost:8084/LeituraWeb/hibernate-mapping-3_0_dtd.dtd">
<!--
Document : Grupo.xml
Created on : 25 de Maio de 2006, 10:42
Author : Genuino Teixeira
Description:
Purpose of the document follows.
-->

<hibernate-mapping>
<class name="br.com.leitura.core.Bairro" table="tbl_bairros">
<id name="codigo" column="CODIGO">
<generator class="sequence">
<param name="sequence">tbl_bairros_codigo_seq</param>
</generator>
</id>
<property name="bairro">
<column name="BAIRRO" not-null="true"/>
</property>
<property name="rua">
<column name="RUA" not-null="true"/>
</property>
<set name="fornecedores" lazy="true" inverse="true" cascade="save-update">
<key column="cod_bairro"/>
<one-to-many class="br.com.leitura.core.Fornecedor"/>
</set>
</class>
</hibernate-mapping>

Código:

...
Bairro bairro = new Bairro();

bairro.setCodigo('1');

bairro.setBairro("bairro");

bairro.setRua("rua");

Cidades cidade = new Cidades();

cidade.setCodigo('2');

cidade.setCidade("cidade");

cidade.setEstado("estado");

Fornecedor fornecedor = new Fornecedor();

fornecedor.setDescontos(0.0);

...

fornecedor.setBairro(bairro);
fornecedor.setCidade(cidade);

bairro.getFornecedores.add(fornecedor);
cidade.getFornecedores.add(fornecedor);

Assuming that "bairro" and "cidade" are registered in cadastre in data base.

The exception:

rg.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at br.com.leitura.dao.LeituraHB.cadastrarFornecedor(LeituraHB.java:378)
at br.com.leitura.core.TrataLeitura.cadastrarFornecedor(TrataLeitura.java:453)
at br.com.leitura.core.TrataLeitura.qualMetodo(TrataLeitura.java:101)
at br.com.leitura.core.TrataLeitura.doGet(TrataLeitura.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.BatchUpdateException: Entrada em lote 0 insert into tbl_fornecedor (NOME, NUMERO, COMPLEMENTO, E_MAIL, CONTATO, descontos, DATA_ATUALIZACAO, HORA_ATUALIZACAO, DATA_CADASTRO, COD_CIDADE, COD_BAIRRO, CNPJ) values (Brasport, 23, NULL, brasport@brasport.com.br, José, 0.0, 2006/06/23, 16:05:05, 2006/06/23, 2, 1, 1) foi abortada. Chame getNextException para ver a causa. at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2435)
at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:397)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1280)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:345)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2497)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 30 more

Please someone help me? It's urgent.

Thank you very much...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.