<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1595" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2><STRONG>Hi,</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2><STRONG>I've a problem with Mapping SQL native with
AS/400:</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>File PCKLft.hbm.xml</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT size=2><FONT size=1><FONT size=2>
<P><FONT size=1><?xml version="1.0"?> </FONT></P>
<P><FONT size=1><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate
Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"></FONT></P>
<P><FONT size=1><hibernate-mapping schema="IB_DAT1"></FONT></P>
<P><FONT size=1><class name="prove.PCKLft" table="PCKLFT"> </FONT></P>
<P><FONT size=1><composite-id></FONT></P>
<P><FONT size=1><key-property name="idn" column="IDN" type="integer"
/></FONT></P>
<P><FONT size=1><key-property name="vrs" column="VRS" type="short"
/></FONT></P>
<P><FONT size=1></composite-id></FONT></P>
<P><FONT size=1><property name="crtpot" column="CRTPOT" type="timestamp"
/></FONT></P>
<P><FONT size=1><property name="crtsbj" column="CRTSBJ" type="integer"
/></FONT></P>
<P><FONT size=1><property name="updpot" column="UPDPOT" type="timestamp"
/></FONT></P>
<P><FONT size=1><property name="updsbj" column="UPDSBJ" type="integer"
/></FONT></P>
<P><FONT size=1><property name="dsc" column="DSC" type="string" length="50"
/> </FONT></P>
<P><FONT size=1><loader query-ref="avanti" /></FONT></P>
<P><FONT size=1></class> </FONT></P>
<P><FONT size=1><sql-query name="avanti"></FONT></P>
<P><FONT size=1><return alias="p" class="prove.PCKLft" /></FONT></P>
<P><FONT size=1>SELECT DSC AS {p.dsc} FROM IB_DAT1.PCKLFT p</FONT></P>
<P><FONT size=1></sql-query></FONT></P>
<P><FONT
size=1></hibernate-mapping></FONT></P></FONT></FONT></FONT></FONT><FONT
face=Arial></FONT></DIV>
<DIV><FONT face=Arial>File hibernate.cfg.xml</FONT></DIV>
<DIV><FONT face=Arial size=2><FONT size=2>
<P><FONT size=1><?xml version='1.0' encoding='utf-8'?></FONT></P>
<P><FONT size=1><!DOCTYPE hibernate-configuration PUBLIC</FONT></P>
<P><FONT size=1>"-//Hibernate/Hibernate Configuration DTD 3.0//EN"</FONT></P>
<P><FONT
size=1>"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"></FONT></P>
<P><FONT size=1><hibernate-configuration></FONT></P>
<P><FONT size=1><session-factory></FONT></P>
<P><FONT size=1><property
name="hibernate.connection.driver_class">com.ibm.as400.access.AS400JDBCDriver</property></FONT></P>
<P><FONT size=1><property
name="hibernate.connection.url">jdbc:as400://192.168.101.4</property></FONT></P>
<P><FONT size=1><property
name="hibernate.connection.username">qsecofr</property></FONT></P>
<P><FONT size=1><property
name="hibernate.connection.password">u348ds</property></FONT></P>
<P><FONT size=1><property
name="dialect">org.hibernate.dialect.DB2400Dialect</property></FONT></P>
<P><FONT size=1><property name="show_sql">true</property></FONT></P>
<P><FONT size=1><property name="transaction.factory_class"></FONT></P>
<P><FONT size=1>org.hibernate.transaction.JDBCTransactionFactory</FONT></P>
<P><FONT size=1></property></FONT></P>
<P><FONT size=1><property
name="hibernate.cache.provider_class"></FONT></P>
<P><FONT size=1>org.hibernate.cache.HashtableCacheProvider</FONT></P>
<P><FONT size=1></property></FONT></P>
<P><FONT size=1><property
name="hibernate.hbm2ddl.auto">update</property></FONT></P>
<P><FONT size=1><mapping resource="prove/PCKLft.hbm.xml"/></FONT></P>
<P><FONT size=1></session-factory></FONT></P>
<P><FONT size=1></hibernate-configuration></FONT></P></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2><STRONG>And the code for the Sql instruction
is:</STRONG></FONT></DIV>
<DIV><STRONG><FONT face=Arial size=2></FONT></STRONG> </DIV>
<DIV><FONT face=Arial size=2>List result =
session.getNamedQuery("avanti")<BR> .setMaxResults(6) <BR> .list();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>But the result is:</STRONG></FONT></DIV>
<DIV><STRONG><FONT face=Arial size=2></FONT></STRONG> </DIV>
<DIV><FONT face=Arial size=2>Hibernate: SELECT DSC FROM IB_DAT1.PCKLFT fetch
first 5 rows only<BR>WARN - SQL Error: -99999, SQLState: 42703<BR>ERROR -
An undefined column name was detected.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>The file PCKLft in the library IB_DAT1 was
created with:</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>CREATE TABLE IB_DAT1/PCKLFT ( <BR>IDN
INT NOT NULL
,
<BR>VRS SMALLINT NOT NULL ,
<BR>CRTPOT TIMESTAMP
,
<BR>CRTSBJ INT
,
<BR>UPDPOT TIMESTAMP
,
<BR>UPDSBJ INT
,
<BR>DSC VARCHAR(50)
,
<BR>PRIMARY KEY (IDN, VRS))
</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>And the SQL with the
code:</STRONG></FONT></DIV>
<DIV><STRONG><FONT face=Arial size=2></FONT></STRONG> </DIV>
<DIV><FONT face=Arial size=2>Query q = session.createQuery("from
PCKLft"); <BR>q.setMaxResults(25);<BR>List result =
q.list(); </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>runs very well. The class runs in a PC with
hibernate3.jar</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2><STRONG>I've used 2 AS/400, both with OS version
V5R2.</STRONG></FONT></DIV>
<DIV><STRONG><FONT face=Arial size=2>It's the first time I don't see the
solution with java and AS/400.</FONT></STRONG></DIV>
<DIV><STRONG><FONT face=Arial size=2>I hope you give to me some
solutions.</FONT></STRONG></DIV>
<DIV><STRONG><FONT face=Arial size=2>THANK YOU!</FONT></STRONG></DIV>
<DIV> </DIV></FONT></DIV>
<DIV><FONT face=Arial size=2>Giovanni Battista Savazzini<BR>Idrosanitaria
Beltrami
S.p.A.<BR>-----------------------------------------------------<BR>Tel.
0522/221729 - 0522/221711<BR>Fax 0522/221730<BR><A
href="mailto:areaelaborazionedati@beltrami.sm">areaelaborazionedati@beltrami.sm</A><BR></FONT></DIV></FONT></DIV></BODY></HTML>