[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3627) String Scalar Function CONCAT and operator || in HQL not working correctly with numeric values

Eric Belanger (JIRA) noreply at atlassian.com
Wed Nov 26 14:54:16 EST 2008


String Scalar Function CONCAT and operator || in HQL not working correctly with numeric values
----------------------------------------------------------------------------------------------

                 Key: HHH-3627
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3627
             Project: Hibernate Core
          Issue Type: Bug
          Components: query-hql
    Affects Versions: 3.3.1
         Environment: MS SQL 2005
            Reporter: Eric Belanger
            Priority: Minor


Since HQL translate the CONCAT and || to + in SQL, numeric values get added together instead of being converted to String and concanated.  Also causes problems when concatenating a numeric with a string.

SELECT CONCAT(1, 2) FROM...

Returns 3 instead of '12'

SELECT CONCAT('TWO', 2) FROM ...

java.sql.SQLException: Conversion failed when converting the varchar value 'TWO' to data type int.

java.sql.SQLException: Conversion failed when converting the varchar value 'TWO' to data type int.
	at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
	at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
	at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
	at net.sourceforge.jtds.jdbc.TdsCore.isDataInResultSet(TdsCore.java:792)
	at net.sourceforge.jtds.jdbc.JtdsResultSet.<init>(JtdsResultSet.java:146)
	at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:424)
	at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:693)
	at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
	at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
	at org.hibernate.loader.Loader.doQuery(Loader.java:674)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
	at org.hibernate.loader.Loader.doList(Loader.java:2220)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
	at org.hibernate.loader.Loader.list(Loader.java:2099)
	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
	at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
	at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
	at org.hibernate.console.HQLQueryPage.getList(HQLQueryPage.java:50)
	at org.hibernate.eclipse.console.views.QueryPageViewer$ContentProviderImpl.getElements(QueryPageViewer.java:114)
	at org.eclipse.jface.viewers.StructuredViewer.getRawChildren(StructuredViewer.java:937)
	at org.eclipse.jface.viewers.ColumnViewer.getRawChildren(ColumnViewer.java:693)
	at org.eclipse.jface.viewers.AbstractTableViewer.getRawChildren(AbstractTableViewer.java:1071)
	at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren(StructuredViewer.java:871)
	at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren(StructuredViewer.java:994)
	at org.eclipse.jface.viewers.AbstractTableViewer.internalRefreshAll(AbstractTableViewer.java:685)
	at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:633)
	at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:620)
	at org.eclipse.jface.viewers.AbstractTableViewer$2.run(AbstractTableViewer.java:576)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1368)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1330)
	at org.eclipse.jface.viewers.AbstractTableViewer.inputChanged(AbstractTableViewer.java:574)
	at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:251)
	at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1606)
	at org.hibernate.eclipse.console.views.QueryPageViewer.createTable(QueryPageViewer.java:218)
	at org.hibernate.eclipse.console.views.QueryPageViewer.createControl(QueryPageViewer.java:197)
	at org.hibernate.eclipse.console.views.QueryPageViewer.<init>(QueryPageViewer.java:154)
	at org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(QueryPageTabView.java:114)
	at org.hibernate.eclipse.console.views.QueryPageTabView$1.contentsChanged(QueryPageTabView.java:78)
	at org.hibernate.eclipse.console.views.QueryPageTabView$1.intervalAdded(QueryPageTabView.java:88)
	at javax.swing.AbstractListModel.fireIntervalAdded(AbstractListModel.java:130)
	at org.hibernate.console.QueryPageModel.add(QueryPageModel.java:67)
	at org.hibernate.console.KnownConfigurations$1.queryPageCreated(KnownConfigurations.java:90)
	at org.hibernate.console.ConsoleConfiguration.fireQueryPageCreated(ConsoleConfiguration.java:419)
	at org.hibernate.console.ConsoleConfiguration.access$5(ConsoleConfiguration.java:415)
	at org.hibernate.console.ConsoleConfiguration$4.execute(ConsoleConfiguration.java:391)
	at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
	at org.hibernate.console.ConsoleConfiguration.executeHQLQuery(ConsoleConfiguration.java:383)
	at org.hibernate.eclipse.hqleditor.HQLEditor.executeQuery(HQLEditor.java:406)
	at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:72)
	at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:52)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.hibernate.eclipse.console.actions.ExecuteQueryAction.runWithEvent(ExecuteQueryAction.java:56)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:546)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
	at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:443)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1101)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3319)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1173)



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list