Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Hibernate Retrieve data using Criteria api

Have Programming Question? Ask it here!
 
 
 


Pintu Ranjan Sai
Retrieve data using Criteria api
1 Answer(s)      3 years ago
Posted in : Hibernate


import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Query; import org.hibernate.Criteria; import org.hibernate.criterion.Restrictions; import org.hibernate.cfg.Configuration; import java.util.*;

class ReadApplication { public static void main(String args[])throws Exception { Configuration configuration=new Configuration(); configuration.configure(); SessionFactory sf=configuration.buildSessionFactory(); Session s=sf.openSession(); Criteria criteria=s.createCriteria(Account.class); criteria.add(Restrictions.gt("balance",20000)); List<Account> l2=criteria.list(); for(Account acc:l2) { System.out.println("Account number "+acc.getAccno()+" detail....."); System.out.println(); System.out.println("Name : "+acc.getName()); System.out.println(); System.out.println("Balance : "+acc.getBalance()); //count++; } s.close(); } } And there is a Account class. when run this in command prompt i get some errors like... Jul 31, 2011 10:23:49 AM org.hibernate.type.NullableType nullSafeSet INFO: could not bind value '20000' to parameter: 1; java.lang.Integer Exception in thread "main" java.lang.ClassCastException: java.lang.Integer at org.hibernate.type.FloatType.set(FloatType.java:37) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65) at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1514 ) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1576) at org.hibernate.loader.Loader.doQuery(Loader.java:661) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo ader.java:224) at org.hibernate.loader.Loader.doList(Loader.java:2145) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) at org.hibernate.loader.Loader.list(Loader.java:2024) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java :94) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) at ReadApplication.main(ReadApplication.java:33)


Advertisement
View Answers

August 1, 2011 at 11:38 AM


Please go through the following link:

Hibernate Tutorials



Related Tutorials/Questions & Answers:
Retrieve data using Criteria api
Retrieve data using Criteria api  import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Query; import...=configuration.buildSessionFactory(); Session s=sf.openSession(); Criteria criteria
Hibernate: ORDER BY using Criteria API.
Hibernate: ORDER BY using Criteria API.  How to display record in order using Criteria API?   Hibernate Criteria API provides an easy way... API is very Simplified API for fetching data from Criterion objects. The criteria
Advertisements
What is criteria API?
on the persistence database. The hibernate criteria API is very Simplified API for fetching data from Criterion objects. The Hibernate Criteria API contains Restriction class... What is criteria API?  Hi, What is criteria API? Thanks,  
criteria api
criteria api  what is the purpose of Restrictions class   Using Restrictions class, we can narrow the result of our query.Here are some restrictions that can also be use to narrow our Criteria query result
Hibernate Criteria API
data from Criterion objects. The criteria API is an alternative of HQL... criteria functions and dynamic queries. Using Criteria API to create...Hibernate Criteria API The API (Application Programming Interface
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
How to Retrieve Data from Facebook Using PHP
How to Retrieve Data from Facebook Using PHP  is this link has right content regards that?? http://techpdf.co.cc/blog/how-to-retrieve-data-from-facebook-using-php
retrieve data from database using jsf
retrieve data from database using jsf  Hello I want an example of source code to retrieve data from database i have a database (oracle) name as db1...),, name ,and city I want after enter value in textbox according idauthor i retrieve
Retrieve data from xml using servlets
Retrieve data from xml using servlets  Hi plz send me the code for retrieving the data from xml File using Servlets.   Hi, Do you want.... Thanks Deepak   Hi, Here is one tutorial: Create XML File using Servlet
Retrieve data from databse using where in JSP
Retrieve data from databse using where in JSP  Hi, can somebody help me? I have a jsp page. in that i want to get data from the database where username is matched. i tried it. but can't get the output. here is the code. please
sending data to google chart api from mysql database using java
sending data to google chart api from mysql database using java  how to send data from mysql database to google chart api using java
How to Retrieve Data from the database and write into excel file using Java
How to Retrieve Data from the database and write into excel file using Java  Hi, I am trying to develop an small application where i trying to retrieve Data from the database and store the details in excel file. Please can
error for getting the data from an api using br.readLine - Development process
error for getting the data from an api using br.readLine  hi the application is hanging while reading the data using readLine() function . actually the data is coming from remote using particular api call see the following code
sending data to google chart api from mysql database using java
sending data to google chart api from mysql database using java  Добовляйтесь в группу "МАЙНКРАФТА" Будьте участниками Группы Помогаите нам и себе Наша группа https://vk.com/club60851464 Есть свой сервер! Хорошая атмосфера
retrieve related data from database using jsp and mysql
retrieve related data from database using jsp and mysql  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example, In Employee.jsp form, When i click employee id value in combo box ,the related employee name will be displayed in text field
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use
How to retrieve data using combo box value in jsp? - JSP-Servlet
How to retrieve data using combo box value in jsp?  Hi freind, I already post this question. I need urgent help from u. pl response me.... All actions in the same page.......  Hi Friend, Please visit
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends... related value.... I am using only this page.. not get value from another page... in combo box from database.. by using select*from studentinformation; But when i
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ... for retrieving data fromm two tables : first table having fields: bookid,name,phno second table having field: seat-id But the data is not retrieved:why so
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ... for retrieving data fromm two tables : first table having fields: bookid,name,phno second table having field: seat-id But the data is not retrieved:why so
how to retrieve data from multiple tables in jsp using javabeans
how to retrieve data from multiple tables in jsp using javabeans   ... for retrieving data fromm two tables : first table having fields: bookid,name,phno second table having field: seat-id But the data is not retrieved:why so
Retrieve data from database by using sql tag of JSTL SQL library
Retrieve data from database by using sql tag of JSTL SQL library... we will see how retrieve data from database using sql query given by user. To execute query first create a data source and then execute sql query
Hibernate Criteria
the different ways of using the Criteria Query. The Hibernate Criteria API...Hibernate Criteria - Learn the Hibernate Criteria API and master the Hibernate framework The Hibernate Criteria query API is used to selectively find
how to retrieve data from database
how to retrieve data from database  unable to retrieve data from database using mySQL by using jsp sessions and beans for editing
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Retrieve data by clicking a link
Retrieve data by clicking a link  In a page there are 5 links.Every link has a hidden value. According to that hidden value data should be retrieved from the database and data should be displayed in a new page.How to do it?Please
how to store,retrieve,modify the data
how to store,retrieve,modify the data  hello sir ,how to store,retrieve,modify the data using the swing please help me
Using sum() in hibernate criteria.
Using sum() in hibernate criteria.  How to calculate sum() in hibernate criteria by using projection?   You can calculate sum of any numeric value in hibernate criteria by using projection. Projection is an interface
store and retrieve data
store and retrieve data  sir,i want to store the entering data in a word file and retrieve it when i need.i am try to develop a video portal.in which... Write data into word file For this, poi-scratchpad-3.7-20101029.jar is needed
uSING JAVA API
uSING JAVA API  How to extract Quickbooks online data using Quickbooks api( Rest ApI) write in java code ? 1.register company account 2... find Quickbooks online data
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
retrieve data from database in java swing form using prev n next buttons
retrieve data from database in java swing form using prev n next buttons  i have a database having columns id(int),path(text),width(int),height(int),avdRed(float),avgGreen(float),avgBlue(float) i have to retrieve all the fields
retrieve data from database in java swing form using prev n next buttons
retrieve data from database in java swing form using prev n next buttons  i have a database having columns id(int),path(text),width(int),height(int),avdRed(float),avgGreen(float),avgBlue(float) i have to retrieve all the fields
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver
How to Retrieve Excel data into mysql using type 2 JDBC-ODBC driver  .... so, can any one help me without creating DNS we should retrieve data from excel using ODBC.plz help me guys..........   Follow these steps: Open Data
Joining tables using criteria
Joining tables using criteria  How do i join more than three tables and retrieve one column from parent table and count of unique values in a single column from child table,the joined tables must be maintain primary key
Retrieve The Data From MySql Datbase
Retrieve The Data From MySql Datbase   How to Retrieve The Data From MYSQL database TO Use Select the Emp_id Option.And Also Search Option
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  Hello friend i want use only one jsp page.. but u give 2 pages... I want to work in one page... Pl response.. I do not need getParameter... Pl respose me
Hibernate Criteria Examples
of using Hibernate Criteria query. With the help of criteria query you can selectively retrieve the data from database. There are many options available... Hibernate Criteria NotEqual Example Hibernate Criteria Hibernate Criteria API
Hibernate criteria query using Max()
Hibernate criteria query using Max()  What is Hibernate criteria query using Max()?   You can find out maximum value in hibernate criteria... in ?org.hibernate.criterion?. For using Projection object in our Criteria, we have to call
Hibernate criteria query using Min().
Hibernate criteria query using Min().  How to find minimum value in Hibernate criteria query using Projection?   You can find out minimum value in hibernate criteria by using projection. Projection is an interface
Hibernate criteria query using avg()
Hibernate criteria query using avg()  How to calculate average in Hibernate criteria query using Projection?   You can calculate average of any numeric values in hibernate criteria by using projection. Projection
Hibernate criteria example using struts2
Hibernate criteria example using struts2 This hibernate criteria example using... API is used for creating dynamic query. With the help of criteria, you can create query without HQL. In this hibernate criteria example using struts2, we
retrieve data from database with hyperlink
retrieve data from database with hyperlink  sir....i have one table called 'name' having two values i have to retrieve those data with a hyperlink... have values C C++ i have to retrieve and if i click C its sub categories should
retrieve data from mysql database
retrieve data from mysql database  hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant data from mysql database using php.... below my code is that.. <html> <head>
Advertisements
 

 

 

DMCA.com