General J2EE: How to execute sql directly in Hibernate?
- Posted by: lyo Yashnoo
- Posted on: September 09 2004 00:45 EDT
I want to execute SQL script using Hibernate.So I want to know whether hibernate can do it.For example: I read some sql statement from a config file . And I want to execute them but don't use JDBC!
Could hibernate do it? THks!
I hope this helps you.
Configuration cfg = new Configuration();
String sql="select * from foo";
You mean that Hibernate don't supply the query session interface. I must create my own connection and execute JDBC code. THank you.I will try it. :-)
Hi, Native SQL is handwritten SQL for all database operations like create, update, delete and select. Hibernate Native Query also support stored procedures. In this example you will be creating Hibernate Application to run your native query to calculate the average of invested amount from the insurance table. In the second example you will write Hibernate Native Query Example to retrieve all the entities from insurance table. Have a look at http://www.roseindia.net/hibernate/hibernate-native-sql.shtml Hope this will help you. Deepak Kumar