Paging hibernate creators. Is this a bug or what?...
since seems like its so puzzling to analyze what happened, i decided to do a JDBC approach to retrieve the data in the view like this...
Code:
try{
Session s = DemoSession.currentSession();
Query q = s.getNamedQuery( "com.test.hibernate.BalanceHistory.getById" );
q.setString( "id", "101104" );
List l = Collections.synchronizedList( q.list());
System.out.println( "---- Using Hibernate Approach ------");
for( Iterator i=l.iterator();i.hasNext();){
BalanceHistory bh = (BalanceHistory)i.next();
System.out.println( "Client ID --> " + bh.getClientId());
System.out.println( "Name --> " + bh.getBrandName());
System.out.println( "Value --> " + bh.getBuyValue());
System.out.println( "-------------------------------" );
}
System.out.println( "---- Using JDBC Approach ------");
Connection c = s.connection();
Statement st = c.createStatement();
ResultSet r = st.executeQuery( "select * from vw_BalanceHistory where clientId = 101104" );
while( r.next()){
System.out.println( "Client ID --> " + r.getString( "clientId" ));
System.out.println( "Name --> " + r.getString( "brandName" ));
System.out.println( "Value --> " + r.getString( "buyPrice" ));
System.out.println( "-------------------------------" );
}
r.close();
st.close();
c.close();
It turns out that the JDBC ResultSet returns the correct contents!.
I really dont understand why Hibernate approach wont work.
Given this reality, I might temporarily revert back using JDBC approach to access views.
But, when I obtain Connection, Statement, ResultSet objects from the Session, do I have to execute close() on each of this object?.
Will Session become prematurely close if I do so?,
coz, Ive got a ServletFilter to properly close the Session.....
Warmest Regards!...