-->
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.  [ 2 posts ] 
Author Message
 Post subject: could not execute native bulk manipulation query
PostPosted: Wed Jul 15, 2009 1:56 pm 
Newbie

Joined: Wed Jul 15, 2009 1:47 pm
Posts: 4
Hello,

I'am using a db MS SQL Server 2005.
When I generateCreateSchemaScript and do a query.executeSQLQuery("...");

I have an error stack saying this error at top : could not execute native bulk manipulation query

In fact, it tries to add foreign key twice, so the db server "throw an exception".

Code:
private static void generateSQLDrop() {

      Session session = hibernateSessionHelper.getSessionFactory()
            .openSession();

      Transaction tx = session.beginTransaction();
      String[] sqls = cfg
            .generateDropSchemaScript( lSessionFactoryImplementor
                  .getDialect() );

      try
      {
         executeUpdate( sqls, session );
         tx.commit();
      }
      catch (Exception e)
      {

      }

   }

private static void executeUpdate(String[] pQueries, Session session)
         throws Exception {

      Statement st = ds.getConnection().createStatement();
      for (String sql : pQueries)
      {
         try
         {
            Query q = session.createSQLQuery( sql );
            q.executeUpdate();
         }
         catch (HibernateException e)
         {
            // TODO Auto-generated catch block
            e.printStackTrace();
            // throw e;
         }

      }
   }


And the error when I launch script :

Quote:
Hibernate: create table msc_action (id numeric(19,0) identity not null, nom nvarchar(255) null unique, primary key (id))
org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:174)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
at org.alfresco.module.msc_core.activite.config.GenerateSQL.executeUpdate(GenerateSQL.java:51)
at org.alfresco.module.msc_core.activite.config.GenerateSQL.generateSQLCreate(GenerateSQL.java:75)
at org.alfresco.module.msc_core.activite.config.GenerateSQL.main(GenerateSQL.java:157)
Caused by: java.sql.SQLException: Il existe déjà un objet nommé 'msc_action' dans la base de données.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2816)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2254)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:631)
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:505)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:165)
... 5 more
Hibernate: create table msc_courrier (id numeric(19,0) not null, natPiece nvarchar(255) null, natContrat nvarchar(255) null, declaration tinyint null, etat numeric(19,0) not null, detenteur numeric(19,0) not null, personne_id numeric(19,0) null, etat_id numeric(19,0) null, primary key (id))
org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:174)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
at org.alfresco.module.msc_core.activite.config.GenerateSQL.executeUpdate(GenerateSQL.java:51)
at org.alfresco.module.msc_core.activite.config.GenerateSQL.generateSQLCreate(GenerateSQL.java:75)
at org.alfresco.module.msc_core.activite.config.GenerateSQL.main(GenerateSQL.java:157)
Caused by: java.sql.SQLException: Il existe déjà un objet nommé 'msc_courrier' dans la base de données.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2816)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2254)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:631)
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:505)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:165)
... 5 more


PS : when I print the sql code generated, It is very good and a copy paste in SQL client do the creation a the tables...why hibernate do not "simply" do the same (execute the statement once) ?

Thanks for your help


Top
 Profile  
 
 Post subject: Re: could not execute native bulk manipulation query
PostPosted: Thu Jul 16, 2009 12:14 pm 
Newbie

Joined: Wed Jul 15, 2009 1:47 pm
Posts: 4
help me please


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

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.