[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3035?page=c...
]
Sergio Eduardo commented on HHH-3035:
-------------------------------------
I've stopped on same BUG...
I need a sql-query that returns only some properties of an entity.
my hibernate-mapping :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="br.gov.bcb.rdr.persistencia.vo">
<class name="RankingQuantidadeVO"
table="RPR_RANKING_PROVISORIO">
<id column="RPR_ID" name="id">
<generator class="native"></generator>
</id>
<property name="mesAno" column="RPR_DT"></property>
<property name="obsReclamacao"
column="RPR_DS_OBS_RECLAMACAO"></property>
<property name="obsCliente"
column="RPR_DS_OBS_CLIENTES"></property>
<property name="qtdClientes"
column="RPR_QT_CLIENTES"></property>
<property name="qtdReclamacoes"
column="RPR_QT_RECLAMACOES"></property>
<property name="qtdSolucionadas"
column="RPR_QT_RECLAMA_SOLUCIONADAS"></property>
<property name="qtdImprocedente"
column="RPR_QT_RECLAMA_IMPROCED_SOLUC"></property>
<property name="qtdEncaminhada"
column="RPR_QT_RECLAMA_ENCAMINHADAS"></property>
<property name="qtdDenuncias"
column="RPR_QT_DENUNCIAS"></property>
<property name="idPessoaBC"
column="IFR_ID_PESSOA_BC"></property>
<property name="idConglomerado"
column="COR_ID"></property>
<many-to-one name="usuarioVO" class="UsuarioVO"
column="URR_ID"></many-to-one>
</class>
<sql-query name="rankingquantidade.select.quantidade.ranking">
<return alias="rnq" class="RankingQuantidadeVO">
<return-property name="idPessoaBC" column="IFR_ID_PESSOA_BC"
/>
<return-property name="idConglomerado" column="COR_ID" />
<return-property name="qtdReclamacoes" column="QNT_REGISTROS"
/>
<return-property name="id" column="RPR_ID" />
</return>
<![CDATA[
select
IFR_ID_PESSOA_BC,
COR_ID,
QNT_REGISTROS,
RPR_ID,
from
RPR_RANKING_PROVISORIO
]]>
</sql-query>
</hibernate-mapping>
and the problem is:
Hibernate tries to look all properties of a mapped class in resultSet generated.
My sql query, brought only 4 properties, but hibernate tried to acess all properties alias
(from resultSet ) and of course, the same error happened 'cause the query must not
bring all fields.
I've looked the hibernate-core 3.2.6 source code and the problem occurs in the method
org.hibernate.persister.entity.AbstractEntityPersister # hydrate
To temporary solve this problem, you should return all mapped properties of your entity in
your custom SQL Query for loading...
If someone knows any better solution, please post it...
could not read column value from result set: MEDFAC1_14_0_; Invalid
column name SQL Error: 17006, SQLState: null
----------------------------------------------------------------------------------------------------------------
Key: HHH-3035
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3035
Project: Hibernate Core
Issue Type: Bug
Components: core, query-criteria, query-hql, query-sql
Affects Versions: 3.2.2
Environment: JDK5 , Hibernate Junit Test case,WIndows XP
Reporter: sanjeev singh
The following is my section of hibernate mapping file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="gov.njdhss.hippocrates.ems.valueobjects">
<class name="HeprEmsMedfacFacilityVO" table="HEPR_MEDFAC">
<id name="medfacId" column="MEDFAC_ID"
type="java.lang.Long">
<generator class="sequence">
<param name="sequence">HEPR_MEDFAC_SEQ</param>
</generator>
</id>
<property name="medfacName" type="java.lang.String"
column="MEDFAC_NAME" update="true" insert="true">
</property>
<property name="facCode" type="java.lang.String"
column="FAC_CODE" update="true" insert="true">
</property>
</class>
<sql-query name="allfacility">
<return alias="facilities" class="HeprEmsMedfacFacilityVO" >
<return-property name="medfacName" column="MEDFAC_NAME"/>
</return>
<![CDATA[
select facilities.MEDFAC_NAME AS medfacName
from HEPR_MEDFAC facilities
]]>
</sql-query>
</hibernate-mapping>
I am trying to execute the query using the following client code:
public List getAllFacility() {
List listAllFacilities = null;
listAllFacilities = getHibernateTemplate().findByNamedQuery(
"allfacility");
return listAllFacilities;
}
The following is the error:
Hibernate:
select
facilities.MEDFAC_NAME AS medfacName
from
HEPR_MEDFAC facilities
- could not read column value from result set: MEDFAC1_14_0_; Invalid column name
- SQL Error: 17006, SQLState: null
- Invalid column name
- Loading XML bean definitions from class path resource
[org/springframework/jdbc/support/sql-error-codes.xml]
- SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle,
PostgreSQL, Sybase]
Any idea if it is a bug or there is any error in my code.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira