-->
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.  [ 4 posts ] 
Author Message
 Post subject: MySQL: SQL String can not be NULL - problem since RC2
PostPosted: Fri Sep 30, 2005 9:58 pm 
Beginner
Beginner

Joined: Thu May 05, 2005 4:49 pm
Posts: 30
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1 RC 2, 3, latest CVS

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 package="com.lodgingservices.domain">
   
   <class name="Activity" table="activities">
     
      <!-- ============================== Common Elements -->
     
      <id name="id" unsaved-value="null">
         <generator class="native"/>
      </id>
     
      <discriminator column="activity_type" type="string" force="false"/>
     
      <version name="version"/>
     
      <property name="created" type="timestamp"/>
     
      <!-- ============================== Properties and Associations -->
     
      <property name="active" column="is_active" type="boolean" not-null="true"/>
     
      <set name="deals" table="activity_deals" sort="natural" cascade="save-update">
         <key column="activity_id"/>
         <many-to-many class="Deal" column="deal_id"/>
      </set>
     
      <property name="displayedInMenu" column="displayed_in_menu" type="boolean"
         not-null="true"/>
     
      <property name="time" type="text"/>
     
      <property name="largeDescription" column="large_description" type="text"/>
     
      <many-to-one name="largePicture" class="Picture" column="large_picture_id"
         unique="true" cascade="all"/>
     
      <property name="name" not-null="true"/>
     
      <property name="policies" type="text"/>
     
      <property name="rateAlias" column="rate_alias" not-null="false"/>
     
      <property name="ratesDisplayedInMenu" column="rates_displayed_in_menu"
         type="boolean" not-null="true"/>
     
      <set name="rateSets" cascade="all-delete-orphan" sort="natural"
         inverse="true">
         <key column="activity_id"/>
         <one-to-many class="RateSet"/>
      </set>
     
      <property name="rateSetUnit" column="rate_set_unit" />
     
      <property name="reservations" type="text"/>
     
      <property name="seasonalDescription" type="text"
         column="seasonal_description"/>
     
      <property name="smallDescription" column="small_description" type="text"/>
     
      <many-to-one name="smallPicture" class="Picture" column="small_picture_id"
         unique="true" cascade="all"/>
     
      <property name="website" type="com.slickapps.hibernate.URLUserType"/>
     
      <!-- ============================== Subclasses -->
     
      <subclass name="com.lodgingservices.domain.resort.ResortActivity"
         discriminator-value="resort">
         <many-to-one name="resort"
            class="com.lodgingservices.domain.resort.Resort"
            column="resort_activity_id" not-null="false"/>
      </subclass>
     
      <subclass name="com.lodgingservices.domain.destination.DestinationActivity"
         discriminator-value="destination">
         <set name="destinations" table="destination_activities"
            cascade="save-update">
            <key column="activity_id"/>
            <many-to-many column="destination_id"
               class="com.lodgingservices.domain.destination.Destination"/>
         </set>
      </subclass>
     
      <subclass name="com.lodgingservices.domain.resort.LodgingActivity"
         discriminator-value="lodging">
         <one-to-one name="resort"
            class="com.lodgingservices.domain.resort.Resort"
            property-ref="lodgingActivity" constrained="true"/>
      </subclass>
     
      <subclass name="com.lodgingservices.domain.Event"
         discriminator-value="event">
         
         <property name="date" type="date" column="date" not-null="false"/>
         
         <property name="endDate" type="date" column="end_date" not-null="false"/>
         
         <property name="location" type="text"/>
         
         <subclass name="com.lodgingservices.domain.resort.ResortEvent"
            discriminator-value="resort_event">
            <many-to-one name="resort"
               class="com.lodgingservices.domain.resort.Resort"
               column="resort_event_id" not-null="false"/>
         </subclass>
         
         <subclass name="com.lodgingservices.domain.destination.DestinationEvent"
            discriminator-value="destination_event">
            <set name="destinations" table="destination_events"
               cascade="save-update">
               <key column="event_id"/>
               <many-to-many column="destination_id"
                  class="com.lodgingservices.domain.destination.Destination"/>
            </set>
         </subclass>
         
      </subclass>
     
   </class>
   
</hibernate-mapping>


Full stack trace of any exception that occurs:
Code:
org.hibernate.exception.GenericJDBCException: could not initialize a collection: [com.lodgingservices.domain.Activity.deals#39]
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.loadCollection(Loader.java:1923)
   at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:71)
   at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
   at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
   at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1563)
   at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
   at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:183)
   at org.hibernate.collection.PersistentSet.remove(PersistentSet.java:184)
   at com.lodgingservices.domain.Deal.removeAllActivities(Deal.java:54)
   at com.lodgingservices.manager.DefaultAdminManager.saveOrUpdateDeal(DefaultAdminManager.java:148)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
   at $Proxy3.saveOrUpdateDeal(Unknown Source)
   at com.lodgingservices.web.admin.deal.EditDealFormController.onSubmit(EditDealFormController.java:119)
   at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:258)
   at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:256)
   at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:139)
   at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)
   at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:357)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
   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.valves.AccessLogValve.invoke(AccessLogValve.java:526)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
   at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
   at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
   at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
   at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: SQL String can not be NULL
   at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:432)
   at com.mysql.jdbc.Connection.clientPrepareStatement(Connection.java:2063)
   at com.mysql.jdbc.Connection.clientPrepareStatement(Connection.java:1996)
   at com.mysql.jdbc.Connection.prepareStatement(Connection.java:4266)
   at com.mysql.jdbc.Connection.prepareStatement(Connection.java:4185)
   at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:185)
   at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:278)
   at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:431)
   at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:366)
   at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)
   at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
   at org.hibernate.loader.Loader.doQuery(Loader.java:661)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
   at org.hibernate.loader.Loader.loadCollection(Loader.java:1916)
   ... 48 more


Name and version of the database you are using:
MySQL 5.0.13 RC1

The generated SQL (show_sql=true):
The SQL String was null when being sent to the DB.

Debug level Hibernate log excerpt:
Code:
2005-09-30 19:26:39,718 DEBUG (AbstractSaveEventListener.java:470) - detached instance of: com.lodgingservices.domain.Deal
2005-09-30 19:26:39,718 DEBUG (DefaultSaveOrUpdateEventListener.java:202) - updating detached instance
2005-09-30 19:26:39,718 DEBUG (DefaultSaveOrUpdateEventListener.java:248) - updating [com.lodgingservices.domain.Deal#6]
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:297) - updating [com.lodgingservices.domain.Deal#6]
2005-09-30 19:26:39,734 DEBUG (AbstractSaveEventListener.java:470) - detached instance of: com.lodgingservices.domain.Activity
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:202) - updating detached instance
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:248) - updating [com.lodgingservices.domain.resort.LodgingActivity#39]
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:297) - updating [com.lodgingservices.domain.resort.LodgingActivity#39]
2005-09-30 19:26:39,734 DEBUG (AbstractSaveEventListener.java:470) - detached instance of: com.lodgingservices.domain.resort.Resort
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:202) - updating detached instance
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:248) - updating [com.lodgingservices.domain.resort.Resort#21]
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:297) - updating [com.lodgingservices.domain.resort.Resort#21]
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:60) - reassociated uninitialized proxy
2005-09-30 19:26:39,734 DEBUG (AbstractSaveEventListener.java:435) - persistent instance of: com.lodgingservices.domain.resort.LodgingActivity
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:105) - ignoring persistent instance
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:142) - object already associated with session: [com.lodgingservices.domain.resort.LodgingActivity#39]
2005-09-30 19:26:39,734 DEBUG (DefaultSaveOrUpdateEventListener.java:60) - reassociated uninitialized proxy
2005-09-30 19:26:39,734 DEBUG (DefaultInitializeCollectionEventListener.java:41) - initializing collection [com.lodgingservices.domain.Activity.deals#39]
2005-09-30 19:26:39,734 DEBUG (DefaultInitializeCollectionEventListener.java:47) - checking second-level cache
2005-09-30 19:26:39,734 DEBUG (DefaultInitializeCollectionEventListener.java:59) - collection not cached
2005-09-30 19:26:39,734 DEBUG (AbstractBatcher.java:344) -
2005-09-30 19:26:39,765 WARN  (JDBCExceptionReporter.java:71) - SQL Error: 0, SQLState: S1009
2005-09-30 19:26:39,765 ERROR (JDBCExceptionReporter.java:72) - SQL String can not be NULL


I've gotten this error ever since I upgraded from 3.1 RC1 to RC2. This is a related thread: http://forum.hibernate.org/viewtopic.php?t=319&start=0&postdays=0&postorder=asc&highlight=

Gavin said he checked in a fix to CVS so I built the latest CVS as of 9/30 7:45MST but no dice. Gavin or others, please let me know what you need from me.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 10:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
How about the client code you see causing this? Also, are you using an interceptor?

Plus, considering we have not even released RC1 yet, I doubt the upgrade from RC1 to RC2 caused your problem here ;)


Top
 Profile  
 
 Post subject: oops
PostPosted: Fri Sep 30, 2005 10:38 pm 
Beginner
Beginner

Joined: Thu May 05, 2005 4:49 pm
Posts: 30
Err... I meant beta 1 versus beta 2.

Steve - you nailed it. My IDE inserted it's skeleton implementation for the onPrepareStatement method in my interceptor, which looked like:

"return null;"

I changed it to return the string parameter and all is good. Thanks very much!


Top
 Profile  
 
 Post subject: better idea
PostPosted: Fri Sep 30, 2005 10:42 pm 
Beginner
Beginner

Joined: Thu May 05, 2005 4:49 pm
Posts: 30
In the future, I will extend the class EmptyInterceptor instead of implementing Interceptor directly. That will ensure I don't do that in future versions.


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