Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
2.1.6
Mapping documents:
<property name="totalBruto"
type="double"
formula="(SELECT SUM(a.UnitPrice * a.Quantity) FROM [Order Details] AS a WHERE a.OrderID = OrderID)"
update="false"
insert="false"
/>
Full stack trace of any exception that occurs:
2005-06-23 16:33:57,318 WARN [net.sf.hibernate.util.JDBCExceptionReporter] SQL Error: 170, SQLState: 37000
2005-06-23 16:33:57,318 ERROR [net.sf.hibernate.util.JDBCExceptionReporter] Line 1: Incorrect syntax near '.'.
2005-06-23 16:33:57,358 WARN [net.sf.hibernate.util.JDBCExceptionReporter] SQL Error: 170, SQLState: 37000
2005-06-23 16:33:57,358 ERROR [net.sf.hibernate.util.JDBCExceptionReporter] Line 1: Incorrect syntax near '.'.
2005-06-23 16:33:57,358 ERROR [net.sf.hibernate.util.JDBCExceptionReporter] SQLException occurred
java.sql.SQLException: Line 1: Incorrect syntax near '.'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:364)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2708)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2150)
at net.sourceforge.jtds.jdbc.TdsCore.clearResponseQueue(TdsCore.java:687)
at net.sourceforge.jtds.jdbc.TdsCore.submitSQL(TdsCore.java:849)
at net.sourceforge.jtds.jdbc.TdsCore.microsoftPrepare(TdsCore.java:1062)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareSQL(ConnectionJDBC2.java:520)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:666)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:289)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:118)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3613)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
at com.farbeyond.ejb.base.BaseBean.getPage(Unknown Source)
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 org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:237)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:98)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
at org.jboss.ejb.Container.invoke(Container.java:738)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:383)
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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
Name and version of the database you are using:
SQLServer 7.0
The generated SQL (show_sql=true):
..., (SELECT SUM(a.UnitPrice * a.Quantity) FROM [Order Details] this.AS this.a WHERE a.OrderID = this.OrderID) as f0_3_, ...
Hi all,
I've defined formula in a property mapping, the above formula does not work with above exception.
But when I change the formula into the following, it works fine :
<property name="totalBruto"
type="double"
formula="(SELECT SUM([Order Details].UnitPrice * [Order Details].Quantity) FROM [Order Details] WHERE [Order Details].OrderID = OrderID)"
update="false"
insert="false"
/>
Do I really have to mention the long table name everywhere in the query ?
Thanks in advanced.
Setya