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: