Hi,
I'm facing problem with getNamedQuery.
My persistent class
public String getOid()
{
return oid;
}
public void setOid(String aOid)
{
oid = aOid;
}
public String getAccNo()
{
return accNo;
}
public void setAccNo(String aAccNo)
{
accNo = aAccNo;
}
public String getAccTitle()
{
return accTitle;
}
public void setAccTitle(String aAccTitle)
{
accTitle = aAccTitle;
}
public String getAccType()
{
return accType;
}
public void setAccType(String aAccType)
{
accType = aAccType;
}
My mapping -
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="ibbl.common.dl.po.AccountPO" table="t_account">
<id name="oid" column="oid" type="string">
<generator class="assigned">
</generator>
</id>
<property name="accNo" column="acc_no" type="string"/>
<property name="accTitle" column="acc_title" type="string"/>
<property name="accType" column="acc_type" type="string"/>
</class>
<sql-query name="mySqlQuery">
<return alias="AccountPO" class="ibbl.common.dl.po.AccountPO"/>
SELECT {AccountPO}.ACC_NO {AccountPO.accNo}
FROM t_account {AccountPO}
</sql-query>
</hibernate-mapping>
My Coding
List people = sess.getNamedQuery("mySqlQuery").list();
if (people != null)
{
Object[] tuple = null;
for (int i=0; i<people.size(); i++)
{
tuple = (Object[])people.get(i);
AppLogger.print("Acc No is: "+tuple[0].toString());
AppLogger.print("Acc Title is: "+tuple[1].toString());
}
}
But giving exceptions like this -
Hibernate:
SELECT AccountPO.ACC_NO acc_no0_
FROM t_account AccountPO
WARN - SQL Error: 17006, SQLState: null
ERROR - Invalid column name
WARN - SQL Error: 17006, SQLState: null
ERROR - Invalid column name
ERROR - SQLException occurred
java.sql.SQLException: Invalid column name
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:285)
at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:5278)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:698)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1505)
at net.sf.hibernate.type.StringType.get(StringType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:352)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:203)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3797)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at ibbl.common.dl.AccountManagerDL.getTestAccNo(AccountManagerDL.java:632)
at ibbl.common.dl.AccountManagerDL.main(AccountManagerDL.java:6673)
net.sf.hibernate.JDBCException: SQLException occurred
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3800)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at ibbl.common.dl.AccountManagerDL.getTestAccNo(AccountManagerDL.java:632)
at ibbl.common.dl.AccountManagerDL.main(AccountManagerDL.java:6673)
Caused by: java.sql.SQLException: Invalid column name
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
Please help me.
Regards.
_________________ I changed from Hibernate 1.2 to Hibernate 2.1 and now giving 'out of memory' error while performing 20 or more operations
|