[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6956) Unknown Parameter: Unknown Coloumname MyColoumn ERRORCODE=-4460, SQLSTATE=null by entityManager.createNativeQuery

Thomas Krippner (JIRA) noreply at atlassian.com
Wed Jan 11 06:56:12 EST 2012


Unknown Parameter: Unknown Coloumname MyColoumn ERRORCODE=-4460, SQLSTATE=null by entityManager.createNativeQuery
-----------------------------------------------------------------------------------------------------------------

                 Key: HHH-6956
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6956
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 3.6.9
         Environment: - JDK 1.6
- WebSphere 7.0 (Windows and zLinux)
- Hibernate 3.6.9-Final
- DB2 OS / 390

            Reporter: Thomas Krippner
            Priority: Critical


If I make a native Query to DB2 with org.hibernate.dialect.DB2390Dialect dialect the org.hibernate.loader.custom.CustomLoader.Metadata Class search the Result Column Names in the Lable Column and not in Columnname.

Problem is Cant make native Queries on Tables with "Label" description.

In line 579 in org.hibernate.loader.custom.CustomLoader is :
return factory.getDialect().getColumnAliasExtractor().extractColumnAlias( resultSetMetaData, position );

The dialect Class is now org.hibernate.dialect.Dialect. At Line 1696 the Extractor gets the Label Extractor to the CustomLoader.

public ColumnAliasExtractor getColumnAliasExtractor() {
	return ColumnAliasExtractor.COLUMN_LABEL_EXTRACTOR;
}

The effect is now, that the extractor get the Label of Tabel as Coloumnname to the rowProcessor. And the JDBC ResultSet can't find the Column.

The ColumnAliasExtractor.COLUMN_NAME_EXTRACTOR is never used in this case and that is the Issue.

My Test:

Persistence.xml
<persistence
   xmlns="http://java.sun.com/xml/ns/persistence"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence_2_0.xsd"
   version="2.0">

  <persistence-unit name="TEST" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>jdbc/DB2</jta-data-source>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>

    <properties>
      <property name="hibernate.ejb.cfgfile" value="db2_config.xml" />
    </properties>
  </persistence-unit>
</persistence>

db2_config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<property name="jta.UserTransaction">java:comp/UserTransaction</property>
		<property name="current_session_context_class">jta</property>
		<property name="dialect">org.hibernate.dialect.DB2390Dialect</property>
		<property name="default_schema">SCHEMA</property>
		<property name="show_sql">true</property>
		<property name="format_sql">true</property>
		<property name="generate_statistics">true</property>
	</session-factory>
</hibernate-configura


EntityManager entityManager = JPAUtil.getEntityManager("TEST");
Query query = entityManager.createNativeQuery("select * from MyTable");
List<Object> ts = (List<Object>) query.getResultList();
System.out.println(ts);

Database Definition is:
CREATE TABLE MyTable
(                                         
   ID DECIMAL(15) NOT NULL   
  ,A DECIMAL(15) NOT NULL   
  ,B INTEGER NOT NULL             
  ,C INTEGER NOT NULL            
  ,D DECIMAL(11, 8) NOT NULL  
)

COMMENT ON TABLE MyTable                                   
  IS 'description';                           
LABEL ON TABLE MyTable                                     
  IS 'Description Two';                               
         LABEL ON MyTable                                  
         (                                                      
           ID IS 'My Column Description'    
         , A IS 'Description A'
         , B IS 'Description B'                    
         , C IS 'Description C'        
         , D IS 'Description D'
         )


On My German System StackTrace
Caused by: com.ibm.db2.jcc.am.SqlException: [jcc][10150][10300][3.62.56] Ungültiger Parameter: Unbekannter My Column Description. ERRORCODE=-4460, SQLSTATE=null
	at com.ibm.db2.jcc.am.fd.a(fd.java:660)
	at com.ibm.db2.jcc.am.fd.a(fd.java:60)
	at com.ibm.db2.jcc.am.fd.a(fd.java:103)
	at com.ibm.db2.jcc.am.hb.a(hb.java:1889)
	at com.ibm.db2.jcc.am.ym.a(ym.java:1803)
	at com.ibm.db2.jcc.am.ym.getShort(ym.java:1562)
	at de.mypackage.basis.sql.ResultSet.getShort(ResultSet.java:825)
	at org.hibernate.type.descriptor.sql.SmallIntTypeDescriptor$2.doExtract(SmallIntTypeDescriptor.java:61)
	at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
	at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:254)
	at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:250)
	at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:235)
	at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.extract(CustomLoader.java:505)
	at org.hibernate.loader.custom.CustomLoader$ResultRowProcessor.buildResultRow(CustomLoader.java:451)
	at org.hibernate.loader.custom.CustomLoader.getResultColumnOrRow(CustomLoader.java:348)
	at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:639)
	at org.hibernate.loader.Loader.doQuery(Loader.java:829)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
	at org.hibernate.loader.Loader.doList(Loader.java:2542)




--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list