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: Erreur org.hibernate.exception.SQLGrammarException
PostPosted: Thu May 11, 2006 5:48 am 
Newbie

Joined: Thu May 11, 2006 5:35 am
Posts: 15
Location: clermont ferrand - France
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.1.3

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
   
   <hibernate-mapping>
   
   <class name="metier.User" table="user">
      <id name="id" type="integer">
         <column name="id"/>
         <generator class="sequence" />
      </id>
   
      <property name="nom" type="string"> </property>
      
   </class>
   
   </hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
Code:
Session session = HibernateUtil.currentSession();
      Transaction tx = session.beginTransaction();
      
      User us = new User();
      us.setNom("Maurice");
      session.save(us);
      
      tx.commit();
      
      HibernateUtil.closeSession();


Full stack trace of any exception that occurs:
Code:
11:31:57,392  INFO Environment:479 - Hibernate 3.1.3
11:31:57,412  INFO Environment:509 - hibernate.properties not found
11:31:57,422  INFO Environment:525 - using CGLIB reflection optimizer
11:31:57,432  INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
11:31:57,652  INFO Configuration:1308 - configuring from resource: /hibernate.cfg.xml
11:31:57,662  INFO Configuration:1285 - Configuration resource: /hibernate.cfg.xml
11:31:57,953  INFO Configuration:469 - Reading mappings from resource: hibernate/User.hbm.xml
XMLScanner#scanComment#text.toString() ==  Hibernate Mapping DTD.


XMLScanner#scanComment#c == 60
11:31:58,323  INFO HbmBinder:309 - Mapping class: metier.User -> user
11:31:58,383  INFO Configuration:1419 - Configured SessionFactory: null
11:31:58,594  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
11:31:58,594  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
11:31:58,604  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
11:31:58,704  INFO DriverManagerConnectionProvider:80 - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/testHibernate
11:31:58,704  INFO DriverManagerConnectionProvider:86 - connection properties: {user=postgres, password=****}
11:31:59,114  INFO SettingsFactory:77 - RDBMS: PostgreSQL, version: 8.1.3
11:31:59,114  INFO SettingsFactory:78 - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.1 JDBC3 with SSL (build 404)
11:31:59,185  INFO Dialect:103 - Using dialect: org.hibernate.dialect.PostgreSQLDialect
11:31:59,235  INFO TransactionFactoryFactory:34 - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
11:31:59,245  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
11:31:59,255  INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
11:31:59,275  INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
11:31:59,285  INFO SettingsFactory:136 - JDBC batch size: 15
11:31:59,285  INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
11:31:59,285  INFO SettingsFactory:144 - Scrollable result sets: enabled
11:31:59,285  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
11:31:59,285  INFO SettingsFactory:160 - Connection release mode: auto
11:31:59,295  INFO SettingsFactory:187 - Default batch fetch size: 1
11:31:59,295  INFO SettingsFactory:191 - Generate SQL with comments: disabled
11:31:59,295  INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
11:31:59,295  INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
11:31:59,305  INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
11:31:59,305  INFO SettingsFactory:203 - Query language substitutions: {}
11:31:59,305  INFO SettingsFactory:209 - Second-level cache: enabled
11:31:59,305  INFO SettingsFactory:213 - Query cache: disabled
11:31:59,305  INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.EhCacheProvider
11:31:59,315  INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
11:31:59,315  INFO SettingsFactory:237 - Structured second-level cache entries: disabled
11:31:59,335  INFO SettingsFactory:264 - Statistics: disabled
11:31:59,335  INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
11:31:59,335  INFO SettingsFactory:283 - Default entity-mode: pojo
Exception in thread "main" org.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 test.Test.main(Test.java:25)
Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into user (nom, id) values (Maurice, 14) a été annulé. Appeler getNextException pour en connaître la cause.
   at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2478)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1298)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2540)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
   ... 8 more
11:31:59,465  INFO SessionFactoryImpl:154 - building session factory
11:32:00,587  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
11:32:00,927  WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: null
11:32:00,937 ERROR JDBCExceptionReporter:72 - L'élément du batch 0 insert into user (nom, id) values (Maurice, 14) a été annulé. Appeler getNextException pour en connaître la cause.
11:32:00,937  WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 42601
11:32:00,937 ERROR JDBCExceptionReporter:72 - ERROR: syntax error at or near "user"
11:32:00,957 ERROR AbstractFlushingEventListener:300 - Could not synchronize database state with session
org.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 test.Test.main(Test.java:25)
Caused by: java.sql.BatchUpdateException: L'élément du batch 0 insert into user (nom, id) values (Maurice, 14) a été annulé. Appeler getNextException pour en connaître la cause.
   at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2478)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1298)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2540)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
   ... 8 more


Name and version of the database you are using:
postgeSQL 8.1

Bonjour tout le monde

Voila, je débute avec hibernate, que je souhaite intégrer dans mon projet et pour l'instant j'essaie un exemple simple mais cela ne veut pas fonctionner.

Or j'obtiens l'erreur suivante que je n'arrive absoluement pas a solutionner. Vous pouvez également consulté ici http://www.developpez.net/forums/showthread.php?t=144216
où j'ai également posté ...

Voila donc si je comprend bien il n'arrive pas a éxecuter l'enregistrement dans ma base et trouve une erreur vers user de mon fichier de mapping mais je ne vois pas quoi ???

Cela va faire 4 jours que je m'arrache les cheveux pour comprendre et faire fonctionner hibernate et cela m'ennuierai fortement de devoir abandonner cette techno (que j'apprend) pour mon projet par faute de temps


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.