-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problems with mapping a Map - "Could not execute JDBC b
PostPosted: Tue May 17, 2005 2:58 pm 
Newbie

Joined: Thu Oct 21, 2004 7:02 am
Posts: 14
Hi,

I'm having some problems with this mapping. Storing a DataElementValidation in the DB works if I set the "context" (Map) to null, but if I try to use a Map, I get the Exception pasted below. Is it something wrong with my mapping below? I expected it had something to do with my session handling, but find it strange that it works when I set the Map to null.

Anyone have any idea?

Thanks,
Kristian

Hibernate version: 3.0.1

Mapping documents: DataElementValidation.hbm.xml
Code:
  <class name="packagename.DataElementValidation">
    <composite-id>
      <key-many-to-one name="dataElement" class="packagename.DataElement"/>
      <key-property name="validator"/>
    </composite-id>
    <map name="context" lazy="false">
      <key>
        <column name="dataElement"/>
        <column name="validator"/>
      </key>
      <map-key type="string"/>
      <element type="string"/>
    </map>
  </class>


Full stack trace of any exception that occurs:
Code:
2005-05-18 01:42:59,625 WARN net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/home/kristian/.m2/repository/ehcache/ehcache/0.7/ehcache-0.7.jar!/ehcache-failsafe.xml
2005-05-18 01:43:01,236 WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
2005-05-18 01:43:01,240 ERROR org.hibernate.util.JDBCExceptionReporter - failed batch
2005-05-18 01:43:01,250 ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
   at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
   at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:179)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:309)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
   at packagename.HibernateTransactionManager.leave(HibernateTransactionManager.java:188)
   at packagename.TransactionInterceptor.invoke(TransactionInterceptor.java:64)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
   at $Proxy2.addDataElementValidation(Unknown Source)
   at packagename.HibernateValidationStoreTest.testBasicDataElementValidation(HibernateValidationStoreTest.java:79)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at junit.textui.TestRunner.doRun(TestRunner.java:116)
   at com.intellij.rt.execution.junit2.IdeaJUnitAgent.doRun(IdeaJUnitAgent.java:57)
   at junit.textui.TestRunner.start(TestRunner.java:172)
   at com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWithArgs(TextTestRunner2.java:23)
   at com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:97)
   at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.sql.BatchUpdateException: failed batch
   at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
   at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:172)
   ... 36 more


Name and version of the database you are using: hsqldb 1.7.2.2


Top
 Profile  
 
 Post subject: Seems to be a problem with hsqldb
PostPosted: Fri May 20, 2005 11:08 am 
Newbie

Joined: Thu Oct 21, 2004 7:02 am
Posts: 14
Now I tried upgrading to Hsqldb 1.7.3.3, didn't help. Setting <property name="hibernate.jdbc.batch_size">20</property> doesn't help.

But when I try testing with MySQL (v. 4.0.23) everything works (without setting jdbc.batch_size).

Anyone know anything about this?


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 21, 2005 12:34 pm 
Newbie

Joined: Thu Oct 21, 2004 7:02 am
Posts: 14
Tried this with hsqldb 1.8.0-RC10 and Hibernate 3.0.3, same problem. I got a tip on setting <property name="hibernate.jdbc.batch_size">0</property>, for getting a better error message. So here's the output of that:

Code:
2005-05-21 21:33:49,825 WARN net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/home/kristian/.m2/repository/ehcache/ehcache/0.7/ehcache-0.7.jar!/ehcache-failsafe.xml
Hibernate: /*insert packagename.DataElement*/insert into DataElement (name, description, active, type, id) values (?, ?, ?, ?, null)
Hibernate: call identity()
Hibernate: /*load packagename.DataElement*/select dataelemen0_.id as id0_, dataelemen0_.name as name2_0_, dataelemen0_.description as descript3_2_0_, dataelemen0_.active as active2_0_, dataelemen0_.type as type2_0_ from DataElement dataelemen0_ where dataelemen0_.id=?
Hibernate: /*insert packagename.DataElementValidation*/insert into DataElementValidation (dataElement, validator) values (?, ?)
Hibernate: /*insert collection row packagename.DataElementValidation.context*/insert into context (dataElement, validator, idx, elt) values (?, ?, ?, ?)
2005-05-21 21:33:51,388 WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: -10, SQLState: 23000
2005-05-21 21:33:51,391 ERROR org.hibernate.util.JDBCExceptionReporter - Try to insert null into a non-nullable column: column: FORMELEMENTTEMPLATE table: CONTEXT in statement [/*insert collection row packagename.DataElementValidation.context*/insert into context (dataElement, validator, idx, elt) values (?, ?, ?, ?)]
2005-05-21 21:33:51,413 ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert collection: [packagename.DataElementValidation.context#component[dataElement,validator]{validator=packagename.MinMaxValidator, dataElement=packagename.DataElement#1}]
   at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
   at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:908)
   at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:23)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:726)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:320)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
   at packagename.HibernateTransactionManager.leave(HibernateTransactionManager.java:188)
   at packagename.TransactionInterceptor.invoke(TransactionInterceptor.java:64)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
   at $Proxy2.addDataElementValidation(Unknown Source)
   at packagename.HibernateValidationStoreTest.testBasicDataElementValidation(HibernateValidationStoreTest.java:83)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at junit.textui.TestRunner.doRun(TestRunner.java:116)
   at com.intellij.rt.execution.junit2.IdeaJUnitAgent.doRun(IdeaJUnitAgent.java:57)
   at junit.textui.TestRunner.start(TestRunner.java:172)
   at com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWithArgs(TextTestRunner2.java:23)
   at com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:97)
   at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.sql.SQLException: Try to insert null into a non-nullable column: column: FORMELEMENTTEMPLATE table: CONTEXT in statement [/*insert collection row packagename.DataElementValidation.context*/insert into context (dataElement, validator, idx, elt) values (?, ?, ?, ?)]
   at org.hsqldb.jdbc.Util.throwError(Unknown Source)
   at org.hsqldb.jdbc.jdbcPreparedStatement.executeUpdate(Unknown Source)
   at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
   at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:889)
   ... 38 more


This is the mapping file:

Code:
<hibernate-mapping>
  <class name="packagename.FormElementTemplateValidation">
    <composite-id>
      <key-many-to-one name="formElementTemplate" class="packagename.FormElementTemplate"/>
      <key-property name="validator"/>
    </composite-id>
    <map name="context" cascade="all-delete-orphan">
      <key>
        <column name="formElementTemplate"/>
        <column name="validator" length="150"/>
      </key>
      <map-key type="string" length="50"/>
      <element type="string"/>
    </map>
  </class>
</hibernate-mapping>


Is it something wrong with how I do the mapping for the map? I've gone through the documentation for this and can't see what's wrong. It works with MySQL...

--
Cheers,
Kristian


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 2:13 am 
Newbie

Joined: Thu Oct 21, 2004 7:02 am
Posts: 14
The problem was (of course) in my mapping. I had two classes, where the map members (Map context) in both of them where mapped to default table names. So both of them where mapped to the same table (context), with different foreign keys. So instead of two foreign keys for each mapped class, I got three...

The obvious question now is of course - why did it work with mysql? That will have to be an exercise for another day =)

Cheers,
Kristian


Top
 Profile  
 
 Post subject: Mapping files for hibernate in Intellij
PostPosted: Fri Mar 13, 2009 5:48 am 
Newbie

Joined: Sat Mar 07, 2009 5:20 am
Posts: 7
Hi,

I am new to Hibernate and Intellij. After loading Hibernate components, i have given Datasource and refreshed tables.

After genereating mapping.xml and java files with this datasource, i am getting mapping java files and mapping.xml for 2 tables only. Actually there are 750 tables have been loaded from my datasource

What mistake i have done? Could you please help me out on this?
Thanks in advance

Sridhar


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.