]
Max Rydahl Andersen commented on HHH-2974:
------------------------------------------
"If the entity is mapped with a many-to-one
to another entity it is required to also return this when performing the native query,
otherwise a database specific "column not found" error will occur. The
additional columns will automatically be returned when using the * notation, but we prefer
to be explicit as in the following example for a many-to-one to a Dog:"
"Native sql queries which query for entities that is mapped as part of an inheritance
must include all properties for the baseclass and all it subclasses."
I guess the last one there could be rephrased to remove the inheritance part since it is
also applicable for base classes.
And yes that code works. Why would you *ever* want an entity to be partial ? then it is
not an entity!
Native SQLQuey combined with addEntity forces to retrieve all
columns
---------------------------------------------------------------------
Key: HHH-2974
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2974
Project: Hibernate3
Issue Type: Bug
Components: core, documentation
Affects Versions: 3.0 alpha, 3.0 beta 1, 3.0 beta 2, 3.0 beta 3, 3.0 beta 4, 3.0 rc 1,
3.0 final, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1 beta 1, 3.1 beta 2, 3.1 rc 1, 3.1 rc2,
3.1 rc3, 3.1, 3.1.1, 3.1.2, 3.2.0.alpha1, 3.2.0.alpha2, 3.1.3, 3.2.0 cr1, 3.2.0.cr2,
3.2.0.cr3, 3.2.0.cr4, 3.2.0.cr5, 3.2.0.ga, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.4.sp1, 3.2.5
Environment: Hibernate 3.2.5, All Databases
Reporter: Philippe Mouawad
Attachments: ArtCondVente.hbm.xml, ArtLibelle.hbm.xml
Hello,
I think it is rather a feature after looking inside Hibernate Code but since I didn't
find anything about it in the Docs Chapter 16
(
http://www.hibernate.org/hib_docs/reference/en/html/querysql.html)
The problem is that If you do not specify <alias>.* in a Native SQL Query it will
fail.
To be clear, it seems that when using addEntity or <return alias="..." />
you cannot retrieve only the column you are interested in. Instead addScalar or
<return-scalar must be used.
I think the documentation shoud explicitely indicate it or the feature shoud be
developped since it would be rather a great feature when native SQL has to be used.
Hibernate Mapping:
Attached file
<sql-query name="getInfoComplEcom">
<return alias="acv"
class="com.kingfisher.chrgtecom.dataobject.ecom.DoArtCondVente" />
<![CDATA[
SELECT
theAcv.CARTICLE as {acv.carticle},
theAcv.CESCLAVE as {acv.cesclave},
theAcv.LARTICLE as {acv.larticle},
theAcv.LARTICLE_RED as {acv.larticleRed}
FROM ART_COND_VENTE theAcv
WHERE theAcv.CARTICLE in (:codeArticles)
]]>
</sql-query>
Java code:
// codeArticles is a List of Integer Ids
Session session = getCurrentSession();
Query query = session.getNamedQuery("getInfoComplEcom");
query.setParameterList("codeArticles",codeArticles);
List result = query.list();
return result;
Missing column is :TMODIF6_0_ , alias column of tmodif property, not in Native Query
Stack:
ERROR:http-8080-Processor4-org.hibernate.util.JDBCExceptionReporter-Nom de colonne non
valide
ERROR:http-8080-Processor4-com.foo.action.ChargerProduitAction-Development error for URI
:'/chrgtecom/main/chargerProduit.do'
org.hibernate.exception.GenericJDBCException: could not execute query
at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert (JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java :2099)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java :142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at com.foo.dao.EcomDao.getInfoComplEcom(EcomDao.java:112)
at com.foo.services.EcomServices.getInfoComplEcom (EcomServices.java:20)
at
com.foo.services.EcomServices$$FastClassByCGLIB$$5dc5078d.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint
(Cglib2AopProxy.java:695)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke
(TransactionInterceptor.java:107)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke
(TransactionInterceptor.java:107)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept
(Cglib2AopProxy.java:630)
at
com.foo.services.EcomServices$$EnhancerByCGLIB$$4ffbebb6.getInfoComplEcom(<generated>)
at com.foo.services.AgileServices.getInfosCompl(AgileServices.java :131)
at com.foo.services.AgileServices.prepareInfosCompl(AgileServices.java:152)
at
com.foo.services.AgileServices$$FastClassByCGLIB$$b720e887.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:695)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
(ReflectiveMethodInvocation.java:144)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
(ReflectiveMethodInvocation.java:166)
at
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:630)
at com.foo.services.AgileServices$$EnhancerByCGLIB$$61330582.prepareInfosCompl
(<generated>)
at com.foo.action.ChargerProduitAction.process(ChargerProduitAction.java:122)
at com.ubikingenierie.fwk.action.GenericAction.execute(GenericAction.java:113)
at org.springframework.web.struts.DelegatingActionProxy.execute
(DelegatingActionProxy.java:110)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at
com.ubikingenierie.fwk.struts.processor.FwkRequestProcessor.process(FwkRequestProcessor.java:142)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost (ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:199)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:145)
at
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java
:63)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:165)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:145)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke
(FilterSecurityInterceptor.java:107)
at
org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter
(FilterChainProxy.java:275)
at
org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java
:275)
at
com.ubikingenierie.fwk.timeout.LoggedOnApplicationFilter.doFilter(LoggedOnApplicationFilter.java:101)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at
org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at
org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:229)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.logout.LogoutFilter.doFilter (LogoutFilter.java:106)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java
:286)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at
org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:138)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at org.acegisecurity.util.FilterToBeanProxy.doFilter (FilterToBeanProxy.java:98)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:165)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java
:145)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:139)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java :198)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2460)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :133)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:119)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext
(StandardPipeline.java:594)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:545)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java
:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:127)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java :433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:157)
at org.apache.coyote.http11.Http11Processor.process (Http11Processor.java:874)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java
:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run (Thread.java:534)
Caused by: java.sql.SQLException: Nom de colonne non valide
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:162)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:3060)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn (OracleResultSetImpl.java:1861)
at
org.apache.commons.dbcp.DelegatingResultSet.findColumn(DelegatingResultSet.java:292)
at org.hibernate.jdbc.ColumnNameCache.getIndexForColumnName(ColumnNameCache.java:28)
at org.hibernate.jdbc.ResultSetWrapper.findColumn(ResultSetWrapper.java:61)
at org.hibernate.jdbc.ResultSetWrapper.getString(ResultSetWrapper.java:225)
at org.hibernate.type.StringType.get(StringType.java :18)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java :81)
at
org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2096)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
at org.hibernate.loader.Loader.instanceNotYetLoaded (Loader.java:1308)
at org.hibernate.loader.Loader.getRow(Loader.java:1206)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 98 more
Hope this is not a duplicate, I searched for a bug or in the forum.
Philippe
http://www.ubik-ingenierie.com
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: