Hibernate version:
3
Mapping documents:
<sql-query name="GestQuery">
<return alias="ge" class="Gest">
<return-property name="nomUsr" column="col1"/>
<return-property name="codPrf" column="col2"/>
<return-property name="nomGut" column="null"/>
<return-property name="melUsr" column="null"/>
</return>
SELECT mup.nom_usr AS col1,
um.mel_usr AS col2,
'' AS null
FROM m_usr_prf mup, OUTER usr_mel um
WHERE mup.nom_usr = um.nom_usr and mup.cod_prf='ges'
</sql-query>
Code between sessionFactory.openSession() and session.close()
try {
session = getHibernateTemplate().getSessionFactory().openSession();
Query q = session.getNamedQuery("GestQuery");
List lst = q.list();
session.close();
} catch (HibernateException e) {
log.error(e.getMessage(), e);
throw new TechnicalException(CLASS_NAME,"error.technical: initCache", e);
}
With all the attributes of my class Gest in a return-property, no problem... all works OK! but an Exception is raised if i forget to feed even 1 attributes of my class called "Gest"
In the thread
http://forum.hibernate.org/viewtopic.ph ... e87130e813
Max said that all attributes ( -> select MyClass.*) must be feeded (in v2.1)
but since version 3 is it possible to feed only few attributes of a Bean ???
I've found a trick : create a virtual column named null with '', then
you add that :
<return-property name="melUsr" column="null"/>
for all your property that don't need to be fed, and ('' AS null) in your query.
What do you think about that trick ?????
Thank you!!!!!
Level
ERROR
Logger
org.hibernate.util.JDBCExceptionReporter
Time
2005-09-27 17:18:35,625
Thread
http-8080-Processor22
Message
No such column name
Full stack trace of any exception that occurs:
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1560)
at org.hibernate.loader.Loader.list(Loader.java:1540)
Name and version of the database you are using:
Informix
The generated SQL (show_sql=true):
Hibernate: SELECT mup.nom_usr AS col1, um.mel_usr AS col2, '' AS null FROM m_usr_prf mup, OUTER usr_mel um WHERE mup.nom_usr = um.nom_usr and mup.cod_prf='ges'