Joined: Wed Mar 16, 2005 12:20 am Posts: 9
|
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3 rc1
Mapping documents:
<hibernate-mapping package="com.tpmex.jessdb"> <class name="Timetable" table="copHorarios" lazy="true"> <composite-id name="id" class="TimetableIden" access="field"> <key-property name="timetableId" type="long"/> <key-property name="instalationId" type="long"/> <key-property name="dayOfWeek" type="int"/> </composite-id> <property name="initialTime" column="InitialTime" type="calendar"/> <property name="finalTime" column="FinalTime" type="calendar"/> <property name="forTrainingUse" column="UsoCapacitacion" type="boolean"/> <loader query-ref="sqlTimetables"/> </class> <class name="TimetableIden" lazy="true"> <id name="timetableId" column="Horario_Id"/> <property name="instalationId" column="Instalacion_Id" type="long"/> <property name="dayOfWeek" column="DayOfWeek" type="int"/> </class> <sql-query name="sqlTimetables" > <return alias="h" class="Timetable" lock-mode="read"/> <return alias="i" class="TimetableIden" lock-mode="read"/> Select Horario_Id as {i.timetableId}, Instalacion_Id as {i.instalationId}, datepart(dw, getdate()) as {i.dayOfWeek}, case datepart(dw, getdate()) when 1 then convert(datetime, domini) when 2 then convert(datetime, lunini) when 3 then convert(datetime, marini) when 4 then convert(datetime, mierini) when 5 then convert(datetime, jueini) when 6 then convert(datetime, vieini) when 7 then convert(datetime, sabini) end as {h.initialTime}, case datepart(dw, getdate()) when 1 then convert(datetime, domfin) when 2 then convert(datetime, lunfin) when 3 then convert(datetime, marfin) when 4 then convert(datetime, mierfin) when 5 then convert(datetime, juefin) when 6 then convert(datetime, viefin) when 7 then convert(datetime, sabfin) end as {h.finalTime}, UsoCapacitacion as {h.forTrainingUse} From copHorarios Where Horario_Id = ? and Instalacion_Id = ? and datepart(dw, getdate()) = ? </sql-query> </hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
TimetableIden searchtime = new TimetableIden(3,1,3); Timetable time = (Timetable) session.get(Timetable.class, searchtime);
Full stack trace of any exception that occurs:
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:1502) at org.hibernate.loader.Loader.list(Loader.java:1482) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1333) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:146) at org.hibernate.persister.entity.NamedQueryLoader.load(NamedQueryLoader.java:55) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2453) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:387) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:368) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:166) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:249) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:123) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:561) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:556) at com.tpmex.jessdb.TestHibernate.<init>(TestHibernate.java:61) at com.tpmex.jessdb.TestHibernate.main(TestHibernate.java:108) Caused by: java.sql.SQLException: Invalid column name timetabl1_0_. at net.sourceforge.jtds.jdbc.JtdsResultSet.findColumn(JtdsResultSet.java:885) at net.sourceforge.jtds.jdbc.JtdsResultSet.getLong(JtdsResultSet.java:893) at org.hibernate.type.LongType.get(LongType.java:26) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80) at org.hibernate.type.ComponentType.hydrate(ComponentType.java:422) at org.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:182) at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:650) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:277) at org.hibernate.loader.Loader.doQuery(Loader.java:384) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203) at org.hibernate.loader.Loader.doList(Loader.java:1499) ... 16 more
Name and version of the database you are using:
MS SQLServer 2000 using jTDS JDBC Driver
The generated SQL (show_sql=true):
Select Horario_Id as Horario1_1_, Instalacion_Id as Instalac2_3_1_, datepart(dw, getdate()) as DayOfWeek3_1_, case datepart(dw, getdate()) when 1 then convert(datetime, domini) when 2 then convert(datetime, lunini) when 3 then convert(datetime, marini) when 4 then convert(datetime, mierini) when 5 then convert(datetime, jueini) when 6 then convert(datetime, vieini) when 7 then convert(datetime, sabini) end as InitialT4_2_0_, case datepart(dw, getdate()) when 1 then convert(datetime, domfin) when 2 then convert(datetime, lunfin) when 3 then convert(datetime, marfin) when 4 then convert(datetime, mierfin) when 5 then convert(datetime, juefin) when 6 then convert(datetime, viefin) when 7 then convert(datetime, sabfin) end as FinalTime2_0_, UsoCapacitacion as UsoCapac6_2_0_ From copHorarios Where Horario_Id = ? and Instalacion_Id = ? and datepart(dw, getdate()) = ?
Debug level Hibernate log excerpt:
<log4j:event logger="org.hibernate.impl.SessionFactoryObjectFactory" timestamp="1110944989523" level="DEBUG" thread="main"> <log4j:message><![CDATA[initializing class SessionFactoryObjectFactory]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.impl.SessionFactoryObjectFactory" timestamp="1110944989525" level="DEBUG" thread="main"> <log4j:message><![CDATA[registered: ff80808102a97b3f0102a97b41500000 (unnamed)]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.impl.SessionFactoryObjectFactory" timestamp="1110944989525" level="INFO" thread="main"> <log4j:message><![CDATA[Not binding factory to JNDI, no JNDI name configured]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.impl.SessionFactoryImpl" timestamp="1110944989525" level="DEBUG" thread="main"> <log4j:message><![CDATA[instantiated session factory]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.impl.SessionFactoryImpl" timestamp="1110944989525" level="INFO" thread="main"> <log4j:message><![CDATA[Checking 0 named queries]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.impl.SessionImpl" timestamp="1110944989556" level="DEBUG" thread="main"> <log4j:message><![CDATA[opened session]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.event.def.DefaultLoadEventListener" timestamp="1110944989563" level="DEBUG" thread="main"> <log4j:message><![CDATA[loading entity: [com.tpmex.jessdb.Timetable#component[timetableId,instalationId,dayOfWeek]{timetableId=3, dayOfWeek=3, instalationId=1}]]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.event.def.DefaultLoadEventListener" timestamp="1110944989563" level="DEBUG" thread="main"> <log4j:message><![CDATA[attempting to resolve: [com.tpmex.jessdb.Timetable#component[timetableId,instalationId,dayOfWeek]{timetableId=3, dayOfWeek=3, instalationId=1}]]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.event.def.DefaultLoadEventListener" timestamp="1110944989563" level="DEBUG" thread="main"> <log4j:message><![CDATA[object not resolved in any cache: [com.tpmex.jessdb.Timetable#component[timetableId,instalationId,dayOfWeek]{timetableId=3, dayOfWeek=3, instalationId=1}]]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.persister.entity.BasicEntityPersister" timestamp="1110944989564" level="DEBUG" thread="main"> <log4j:message><![CDATA[Materializing entity: [com.tpmex.jessdb.Timetable#component[timetableId,instalationId,dayOfWeek]{timetableId=3, dayOfWeek=3, instalationId=1}]]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.persister.entity.NamedQueryLoader" timestamp="1110944989564" level="DEBUG" thread="main"> <log4j:message><![CDATA[loading entity: com.tpmex.jessdb.Timetable using named query: sqlTimetables]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.impl.SessionImpl" timestamp="1110944989574" level="DEBUG" thread="main"> <log4j:message><![CDATA[setting flush mode to: NEVER]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.impl.SessionImpl" timestamp="1110944989581" level="DEBUG" thread="main"> <log4j:message><![CDATA[SQL query: Select Horario_Id as Horario1_1_, Instalacion_Id as Instalac2_3_1_, datepart(dw, getdate()) as DayOfWeek3_1_, case datepart(dw, getdate()) when 1 then convert(datetime, domini) when 2 then convert(datetime, lunini) when 3 then convert(datetime, marini) when 4 then convert(datetime, mierini) when 5 then convert(datetime, jueini) when 6 then convert(datetime, vieini) when 7 then convert(datetime, sabini) end as InitialT4_2_0_, case datepart(dw, getdate()) when 1 then convert(datetime, domfin) when 2 then convert(datetime, lunfin) when 3 then convert(datetime, marfin) when 4 then convert(datetime, mierfin) when 5 then convert(datetime, juefin) when 6 then convert(datetime, viefin) when 7 then convert(datetime, sabfin) end as FinalTime2_0_, UsoCapacitacion as UsoCapac6_2_0_ From copHorarios Where Horario_Id = ? and Instalacion_Id = ? and datepart(dw, getdate()) = ? ]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.jdbc.AbstractBatcher" timestamp="1110944989584" level="DEBUG" thread="main"> <log4j:message><![CDATA[about to open PreparedStatement (open PreparedStatements: 0, globally: 0)]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.jdbc.AbstractBatcher" timestamp="1110944989584" level="DEBUG" thread="main"> <log4j:message><![CDATA[opening JDBC connection]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.connection.DriverManagerConnectionProvider" timestamp="1110944989584" level="DEBUG" thread="main"> <log4j:message><![CDATA[total checked-out connections: 0]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.connection.DriverManagerConnectionProvider" timestamp="1110944989587" level="DEBUG" thread="main"> <log4j:message><![CDATA[using pooled JDBC connection, pool size: 0]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.SQL" timestamp="1110944989587" level="DEBUG" thread="main"> <log4j:message><![CDATA[ Select Horario_Id as Horario1_1_, Instalacion_Id as Instalac2_3_1_, datepart(dw, getdate()) as DayOfWeek3_1_, case datepart(dw, getdate()) when 1 then convert(datetime, domini) when 2 then convert(datetime, lunini) when 3 then convert(datetime, marini) when 4 then convert(datetime, mierini) when 5 then convert(datetime, jueini) when 6 then convert(datetime, vieini) when 7 then convert(datetime, sabini) end as InitialT4_2_0_, case datepart(dw, getdate()) when 1 then convert(datetime, domfin) when 2 then convert(datetime, lunfin) when 3 then convert(datetime, marfin) when 4 then convert(datetime, mierfin) when 5 then convert(datetime, juefin) when 6 then convert(datetime, viefin) when 7 then convert(datetime, sabfin) end as FinalTime2_0_, UsoCapacitacion as UsoCapac6_2_0_ From copHorarios Where Horario_Id = ? and Instalacion_Id = ? and datepart(dw, getdate()) = ? ]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.jdbc.AbstractBatcher" timestamp="1110944989601" level="DEBUG" thread="main"> <log4j:message><![CDATA[preparing statement]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.type.LongType" timestamp="1110944989608" level="DEBUG" thread="main"> <log4j:message><![CDATA[binding '3' to parameter: 1]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.type.LongType" timestamp="1110944989608" level="DEBUG" thread="main"> <log4j:message><![CDATA[binding '1' to parameter: 2]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.type.IntegerType" timestamp="1110944989608" level="DEBUG" thread="main"> <log4j:message><![CDATA[binding '3' to parameter: 3]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.jdbc.AbstractBatcher" timestamp="1110944989626" level="DEBUG" thread="main"> <log4j:message><![CDATA[about to open ResultSet (open ResultSets: 0, globally: 0)]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.loader.Loader" timestamp="1110944989626" level="DEBUG" thread="main"> <log4j:message><![CDATA[processing result set]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.loader.Loader" timestamp="1110944989627" level="DEBUG" thread="main"> <log4j:message><![CDATA[result set row: 0]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.jdbc.AbstractBatcher" timestamp="1110944989627" level="DEBUG" thread="main"> <log4j:message><![CDATA[about to close ResultSet (open ResultSets: 1, globally: 1)]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.jdbc.AbstractBatcher" timestamp="1110944989627" level="DEBUG" thread="main"> <log4j:message><![CDATA[about to close PreparedStatement (open PreparedStatements: 1, globally: 1)]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.jdbc.AbstractBatcher" timestamp="1110944989627" level="DEBUG" thread="main"> <log4j:message><![CDATA[closing statement]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.util.JDBCExceptionReporter" timestamp="1110944989630" level="DEBUG" thread="main"> <log4j:message><![CDATA[could not execute query [ Select Horario_Id as Horario1_1_, Instalacion_Id as Instalac2_3_1_, datepart(dw, getdate()) as DayOfWeek3_1_, case datepart(dw, getdate()) when 1 then convert(datetime, domini) when 2 then convert(datetime, lunini) when 3 then convert(datetime, marini) when 4 then convert(datetime, mierini) when 5 then convert(datetime, jueini) when 6 then convert(datetime, vieini) when 7 then convert(datetime, sabini) end as InitialT4_2_0_, case datepart(dw, getdate()) when 1 then convert(datetime, domfin) when 2 then convert(datetime, lunfin) when 3 then convert(datetime, marfin) when 4 then convert(datetime, mierfin) when 5 then convert(datetime, juefin) when 6 then convert(datetime, viefin) when 7 then convert(datetime, sabfin) end as FinalTime2_0_, UsoCapacitacion as UsoCapac6_2_0_ From copHorarios Where Horario_Id = ? and Instalacion_Id = ? and datepart(dw, getdate()) = ? ]]]></log4j:message> <log4j:throwable><![CDATA[java.sql.SQLException: Invalid column name timetabl1_0_. at net.sourceforge.jtds.jdbc.JtdsResultSet.findColumn(JtdsResultSet.java:885) at net.sourceforge.jtds.jdbc.JtdsResultSet.getLong(JtdsResultSet.java:893) at org.hibernate.type.LongType.get(LongType.java:26) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80) at org.hibernate.type.ComponentType.hydrate(ComponentType.java:422) at org.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:182) at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:650) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:277) at org.hibernate.loader.Loader.doQuery(Loader.java:384) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203) at org.hibernate.loader.Loader.doList(Loader.java:1499) at org.hibernate.loader.Loader.list(Loader.java:1482) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1333) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:146) at org.hibernate.persister.entity.NamedQueryLoader.load(NamedQueryLoader.java:55) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2453) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:387) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:368) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:166) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:249) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:123) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:561) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:556) at com.tpmex.jessdb.TestHibernate.<init>(TestHibernate.java:61) at com.tpmex.jessdb.TestHibernate.main(TestHibernate.java:108) ]]></log4j:throwable> </log4j:event>
<log4j:event logger="org.hibernate.util.JDBCExceptionReporter" timestamp="1110944989633" level="WARN" thread="main"> <log4j:message><![CDATA[SQL Error: 0, SQLState: 07009]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.util.JDBCExceptionReporter" timestamp="1110944989633" level="ERROR" thread="main"> <log4j:message><![CDATA[Invalid column name timetabl1_0_.]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.impl.SessionImpl" timestamp="1110944989636" level="DEBUG" thread="main"> <log4j:message><![CDATA[setting flush mode to: AUTO]]></log4j:message> </log4j:event>
<log4j:event logger="org.hibernate.event.def.DefaultLoadEventListener" timestamp="1110944989636" level="INFO" thread="main"> <log4j:message><![CDATA[Error performing load command]]></log4j:message> <log4j:throwable><![CDATA[org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:1502) at org.hibernate.loader.Loader.list(Loader.java:1482) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1333) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:146) at org.hibernate.persister.entity.NamedQueryLoader.load(NamedQueryLoader.java:55) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2453) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:387) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:368) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:166) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:249) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:123) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:561) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:556) at com.tpmex.jessdb.TestHibernate.<init>(TestHibernate.java:61) at com.tpmex.jessdb.TestHibernate.main(TestHibernate.java:108) Caused by: java.sql.SQLException: Invalid column name timetabl1_0_. at net.sourceforge.jtds.jdbc.JtdsResultSet.findColumn(JtdsResultSet.java:885) at net.sourceforge.jtds.jdbc.JtdsResultSet.getLong(JtdsResultSet.java:893) at org.hibernate.type.LongType.get(LongType.java:26) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80) at org.hibernate.type.ComponentType.hydrate(ComponentType.java:422) at org.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:182) at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:650) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:277) at org.hibernate.loader.Loader.doQuery(Loader.java:384) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203) at org.hibernate.loader.Loader.doList(Loader.java:1499) ... 16 more ]]></log4j:throwable> </log4j:event>
|
|