You have given a sql query "Select insurance.lngInsuranceId, insurance.insuranceName, insurance.investementAmount, insurance.investementDate from Insurance insurance"
In this the last Insurance insurance what does it signify?
Is it Class name and Table name respctively??
in hql query when i am iterating using the iterator it is saying that cannot convert int to int to Insurance.I have tried a lot but it is not comming.Here is the code of yours only.I am tring your example only in myeclipse....reply me soon
String Sql_Query="Select insurance.id,insurance.insurance_name," +
"insurance.investement_amount,insurance.investment_date from Insurance insurance";
Query query=hsession.createQuery(Sql_Query);
for(Iterator it=(Iterator)query.iterate();it.hasNext();)
{
Cannot convert int to Insurance(error) ->
Insurance insurance=(Insurance)it.next();
System.out.println("ID"+insurance.getId());
System.out.println("Name"+insurance.getInsuranceName());
}
In case of web applications, the SessionFactory should be accessed in a singleton way, it can cause out-of-memory-error otherwise. Since the above program is a demo example, standalone and run once, it is fine. Take Care of this in real projects.
table and class namejayesh patil November 30, 2011 at 1:51 PM
You have given a sql query "Select insurance.lngInsuranceId, insurance.insuranceName, insurance.investementAmount, insurance.investementDate from Insurance insurance" In this the last Insurance insurance what does it signify? Is it Class name and Table name respctively??
about hql QueryS.Raghavendra February 9, 2012 at 2:50 PM
in hql query when i am iterating using the iterator it is saying that cannot convert int to int to Insurance.I have tried a lot but it is not comming.Here is the code of yours only.I am tring your example only in myeclipse....reply me soon String Sql_Query="Select insurance.id,insurance.insurance_name," + "insurance.investement_amount,insurance.investment_date from Insurance insurance"; Query query=hsession.createQuery(Sql_Query); for(Iterator it=(Iterator)query.iterate();it.hasNext();) { Cannot convert int to Insurance(error) -> Insurance insurance=(Insurance)it.next(); System.out.println("ID"+insurance.getId()); System.out.println("Name"+insurance.getInsuranceName()); }
class cast exception occursRamakrishna Brahma August 30, 2012 at 2:16 PM
Object[] row=(Object[]) it.next(); this line class cast exception occurs how to solve it
hibernate querysontos September 13, 2012 at 10:58 PM
very good---------------
SessionFactory should be singletonChandrashekhar November 3, 2012 at 7:32 PM
In case of web applications, the SessionFactory should be accessed in a singleton way, it can cause out-of-memory-error otherwise. Since the above program is a demo example, standalone and run once, it is fine. Take Care of this in real projects.
Post your Comment