Hibernate version: 2.1.8
Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping
>
<class
name="at.siemens.sx.core.service.fileexchange.FXOrderDAO"
table="SXFXORDER"
polymorphism="explicit"
dynamic-update="true"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<cache usage="read-write" />
<id
name="id"
column="id"
type="java.lang.Integer"
>
<generator class="native">
<param name="sequence">fxorderid_seq</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-FXOrderDAO.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="orderName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="orderName"
length="30"
not-null="true"
/>
<property
name="state"
type="int"
update="true"
insert="true"
access="property"
column="state"
not-null="true"
/>
<property
name="attempt"
type="int"
update="true"
insert="true"
access="property"
column="attempt"
not-null="true"
/>
<property
name="fileName"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="fileName"
length="255"
not-null="true"
/>
<property
name="fileDate"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="fileDate"
not-null="true"
/>
<property
name="fileSize"
type="long"
update="true"
insert="true"
access="property"
column="fileSize"
not-null="true"
/>
<property
name="watchDog"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="watchDog"
not-null="true"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-FXOrderDAO.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
List dbOrders = session.createCriteria(FXOrderDAO.class)
.add( Expression.eq("orderName", order.getOrderName()) )
.add( Expression.le("watchDog", new Date()) )
.addOrder( Order.asc("fileDate"))
.setMaxResults(noOfFreeWorkers)
.setLockMode(LockMode.UPGRADE)
.list();
Full stack trace of any exception that occurs:Code:
net.sf.hibernate.exception.SQLGrammarException: Unable to perform find
at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3663)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
at at.siemens.sx.core.service.fileexchange.FXTransferController.run(FXTransferController.java:91)
Caused by: java.sql.SQLException: Syntax error or access violation message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 5' at line 1"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:296)
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:324)
at at.siemens.sx.core.service.performance.DataSourceDelegator$DataSourceInvokationHandler.invoke(DataSourceDelegator.java:134)
at $Proxy57.executeQuery(Unknown Source)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:89)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:880)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:273)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:118)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3660)
... 2 more
Name and version of the database you are using: mysql-4.1.5-gamma-win
The generated SQL (show_sql=true):Code:
select this.id as id0_, this.orderName as orderName0_, this.state as state0_, this.attempt as attempt0_, this.fileName as fileName0_, this.fileDate as fileDate0_, this.fileSize as fileSize0_, this.watchDog as watchDog0_ from SXFXORDER this where this.orderName=? and this.watchDog<=? order by this.fileDate asc for update limit ?
after the following changes the SQL statement works correct.
... order by this.fileDate asc limit ? for update
Thank you for your assistance
br
Ramses