-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: facing probelm with getNamedQuery
PostPosted: Thu Jun 10, 2004 7:11 am 
Newbie

Joined: Sat Jan 24, 2004 8:54 am
Posts: 4
Location: Bangladesh
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 10, 2004 7:34 am 
Newbie

Joined: Sat Oct 11, 2003 1:47 pm
Posts: 17
I guess you need to specify all columns of ur table if you are explicitly specifying property names in SQL Queries.
From Section 13.2 of Hibernate docs
Note: if you list each property explicitly, you must include all properties of the class and its subclasses!

I also have a similar issue and am trying to find a workaround for it.

By the way, for ur situation, this looks an overkill!!

Cheers
Raja


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.