[hibernate-issues] [Hibernate-JIRA] Created: (HBX-1127) import.sql doesn't work with scalar variables in SQL 2005

Joseph Miller (JIRA) noreply at atlassian.com
Fri Jun 26 00:57:33 EDT 2009


import.sql doesn't work with scalar variables in SQL 2005
---------------------------------------------------------

                 Key: HBX-1127
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1127
             Project: Hibernate Tools
          Issue Type: Bug
         Environment: Hibernate 3.3.1.GA, Microsoft SQL Server 2005
            Reporter: Joseph Miller


I have in my import.sql the following (which works fine when run directly against the server):

declare @today DATETIME;
set @today = cast( floor( cast( getdate() as decimal(12,5))) as datetime);

(The same error also happens when I use 'select @today = cast( .... )' )

However, when the import.sql is run by Hibernate at startup I get:

12:55:33,099 ERROR [SchemaExport] schema export unsuccessful
org.hibernate.JDBCException: Error during import script execution at line 2
        at org.hibernate.tool.hbm2ddl.SchemaExport.importScript(SchemaExport.java:332)
        at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:264)
        at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:211)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:343)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
        at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)
        at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
        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.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:103)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor1602.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
....   
     at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
Caused by: java.sql.SQLException: Must declare the scalar variable "@today".
        at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
        at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2816)
        at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2254)
        at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:631)
        at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:584)
        at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:546)
        at net.sourceforge.jtds.jdbc.JtdsStatement.executeImpl(JtdsStatement.java:723)
        at net.sourceforge.jtds.jdbc.JtdsStatement.execute(JtdsStatement.java:1157)
        at org.jboss.resource.adapter.jdbc.WrappedStatement.execute(WrappedStatement.java:84)
        at org.hibernate.tool.hbm2ddl.SchemaExport.importScript(SchemaExport.java:328)
        ... 105 more

-- 
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