Hi,
I am new to Hibernate. I have written a simple Hibernate query to return the data from a Oracle (View). Based on the where condition there are 15 records in Database. When i run my Hibernate query it returns 15 rows but it is returning first record 15 times. Please help me in resolving this problem.
Here is my Pojo Class SPView.Java
public class SPView implements java.io.Serializable { private Long sPid; private Long sid; private Long acctid; private Long swid; private String fName; }
It has respective setters and getters
My hbm file is SPView.hbm.xml
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping> <class name="com.SPView" table="S_P_VIEW" schema="xyz"> <id name="sPid" type="java.lang.Long"> <column name="S_P_ID" precision="18" scale="0" /> <generator class="assigned" /> </id> <property name="sid" type="java.lang.Long"> <column name="S_ID" precision="20" scale="0" not-null="true" /> </property> <property name="acctid" type="java.lang.Long"> <column name="ACCT_ID" precision="18" scale="0" not-null="true" /> </property> <property name="swid" type="java.lang.Long"> <column name="SW_ID" precision="18" scale="0" /> </property> <property name="fName" type="java.lang.String"> <column name="F_NAME" length="64" not-null="true" /> </property> <query name="getSPVWDetails"> <![CDATA[FROM SPView a WHERE a.sPSid= :spSid]]> </query>
</class> </hibernate-mapping>
public ArrayList getSPVwDetails(Long spSid) { //Session session = null; SPView spv = null; List<SPView> spViewList = new ArrayList<SPView>(); session = getSession(); Query query = session.getNamedQuery("com.SPView.getSPVWDetails"); query.setLong("spSid", spSid); System.out.println("Query" + query.toString()); spViewList = query.list(); System.out.println("List Size " + query.list().size()); for(int index=0; index<spViewList.size();index++) { spv= spViewList.get(index); System.out.println(" Service Feature Name = " + spv.getFName()); System.out.println(" Service Feature Sid = " + spv.getSFSid()); System.out.println("Index" + index); System.out.println("--------------------------"); } session.close(); return (ArrayList) spViewList; }
Is it the tables in that view is creating the problem ?
Thanks, Sam
|