-->
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.  [ 3 posts ] 
Author Message
 Post subject: Can someone please explain the following exception...
PostPosted: Tue Mar 15, 2005 12:58 am 
Beginner
Beginner

Joined: Fri Dec 10, 2004 11:46 pm
Posts: 37
Oviously the querry is failing but why woudl it fail? Thanks

Hibernate version: 2.1.x

Mapping documents:
Code:
<hibernate-mapping>

   <class name="org.mamoth.Principal" table="Principals">
      <id name="principalID" column="PrincipalID" type="int" unsaved-value="0">
              <generator class="identity" />
      </id>
      <property name="principal" type="java.lang.String">
         <column name="Principal" sql-type="varchar" length="50" not-null="true"/>
      </property>
      <property name="password" type="java.lang.String">
         <column name="Password" sql-type="varchar" length="50" not-null="true"/>
      </property>
      <property name="uuid" type="java.lang.String">
         <column name="UUID" sql-type="varchar" length="50" not-null="true"/>
      </property>
      <property name="active" type="boolean">
         <column name="Active" sql-type="bit"/>
      </property>
   </class>

   <class name="org.mamoth.Role" table="Roles">
      <id name="roleID" column="RoleID" type="int" unsaved-value="0">
              <generator class="identity" />
      </id>
      <property name="role" type="java.lang.String">
         <column name="Role" sql-type="varchar" length="50" not-null="true"/>
      </property>
      <property name="roleGroup" type="java.lang.String">
         <column name="RoleGroup" sql-type="varchar" length="50" not-null="false"/>
      </property>
      
      <many-to-one name="principal" class="org.mamoth.Principal" property-ref="principal"/>
   </class>


   <class name="org.mamoth.Genre" table="Genres">
      <id name="genreID" column="GenreID" type="int" unsaved-value="0">
              <generator class="assigned" />
      </id>
      <property name="genre" type="java.lang.String">
         <column name="Genre" sql-type="varchar" length = "25" not-null="true"/>
      </property>
      <property name="description" type="java.lang.String">
         <column name="Description" sql-type="varchar" length="100" not-null="false"/>
      </property>      
   </class>

   <class name="org.mamoth.Artist" table="Artists">
      <id name="artistID" column="ArtistID" type="int" unsaved-value="0">
              <generator class="identity" />
      </id>
      <property name="principal" type="java.lang.String">
         <column name="Principal" sql-type="varchar" length = "50" not-null="false"/>
      </property>
      <property name="name" type="java.lang.String">
         <column name="Name" sql-type="varchar" length="50" not-null="false"/>
      </property>
      <property name="bookingEmail" type="java.lang.String">
         <column name="BookingEmail" sql-type="varchar" length="50" not-null="false"/>
      </property>
      <property name="webSiteURL" type="java.lang.String">
         <column name="WebSiteURL" sql-type="varchar" length="100" not-null="false"/>
      </property>
      <property name="bio" type="java.lang.String">
         <column name="Bio" sql-type="varchar" length="1000" not-null="false"/>
      </property>
      <property name="picture" type="java.lang.String">
         <column name="Picture" sql-type="varchar" length="50" not-null="false"/>
      </property>      

      <many-to-one name="genre" column="GenreID" class="org.mamoth.Genre"/>

   </class>
   
   <class name="org.mamoth.Music" table="Music">
      <id name="musicID" column="MusicID" type="int" unsaved-value="0">
              <generator class="identity" />
      </id>
      <property name="title" type="java.lang.String">
         <column name="Title" sql-type="varchar" length="50" not-null="true"/>
      </property>
      <property name="year" type="java.lang.String">
         <column name="Year" sql-type="varchar" length="4" not-null="true"/>
      </property>
      <property name="length" type="java.lang.String">
         <column name="Length" sql-type="varchar" length="10" not-null="true"/>
      </property>
      <property name="bitrate" type="java.lang.String">
         <column name="Bitrate" sql-type="varchar" length="10" not-null="true"/>
      </property>
      <property name="file" type="java.lang.String">
         <column name="File" sql-type="varchar" length="50" not-null="false"/>
      </property>
      
      <many-to-one name="artist" column="ArtistID" class="org.mamoth.Artist"/>

      <many-to-one name="genre" column="GenreID" class="org.mamoth.Genre"/>
   </class>

</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
Code:
    public List getMusicListByArtistID(int artistID)
    {
        List musicList = new ArrayList();
       
        try
      {
            Session hSession = HibernateSessionFactory.currentSession();
            HibernateSessionFactory.beginTransaction();

            musicList = hSession.find("from Music as music where music.artistID = ?", new Integer(artistID), Hibernate.INTEGER);
           
            HibernateSessionFactory.commitTransaction();
        }
        catch (HibernateException e)
      {
            HibernateSessionFactory.rollbackTransaction();
           
            e.printStackTrace();
        }
        finally
      {
            HibernateSessionFactory.closeSession();
        }
       
        return(musicList);
    }

Full stack trace of any exception that occurs:
Code:
23:43:28,640 INFO  [STDOUT] org.mamoth.utils.NestedRuntimeException: There was a
problem rolling back the Hibernate transaction; nested exception is:
        net.sf.hibernate.TransactionException: Rollback failed with SQL exceptio
n:
23:43:28,656 INFO  [STDOUT] net.sf.hibernate.TransactionException: Rollback fail
ed with SQL exception:
        at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction
.java:91)
        at org.mamoth.utils.HibernateSessionFactory.rollbackTransaction(Hibernat
eSessionFactory.java:146)
        at org.mamoth.dao.MusicDAOImpl.getMusicListByArtistID(MusicDAOImpl.java:
146)
        at org.apache.jsp.artists.music_005fform_jsp._jspService(music_005fform_
jsp.java:174)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
92)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
        at org.mamoth.UserInfoFilter.doFilter(UserInfoFilter.java:69)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:186)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:75)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:186)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:152)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:44)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:540)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:169)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:137)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:118)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:16
0)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
        at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.SQLException: Can't call rollback when autocommit=true
        at com.mysql.jdbc.Connection.rollback(Connection.java:1445)
        at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcRoll
back(BaseWrapperManagedConnection.java:515)
        at org.jboss.resource.adapter.jdbc.WrappedConnection.rollback(WrappedCon
nection.java:460)
        at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction
.java:86)
        ... 45 more


Name and version of the database you are using:
My SQL 4.0.x

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 3:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Well, your Music class has no such property named artistID, which you attempt to reference in the HQL query.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 10:05 am 
Beginner
Beginner

Joined: Fri Dec 10, 2004 11:46 pm
Posts: 37
Yeah I noticed that after!

I fixed the problem by adding the property and then setting insert="false" update="false for that column...

Now because I map to my Artist, would it be possible to use find to search the music by the artist object?

Thanks


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