In this example we will show you how you can use Native SQL with hibernate. You will learn how to use Native to insert data into database. Native SQL is handwritten SQL for all database operations like insert, update, delete and select. (Take note: This is Your headline).
Take note and eat your words "... is handwritten SQL...
Here's your handwritten SQL, you fake:
session.createSQLQuery.("Insert into [table] values(val1,val2)").executeUpdate();
session.createSQLQuery.("Update [table] set [field]=val where [condition]").executeUpdate();
session.createSQLQuery.("Delete from [table] where [condition]").executeUpdate();
List lst=session.createSQLQuery("Select * from [table]).list();
All of the above "SQL statements" ( take note: statements not your funny set this and set that sess.save())... all done without entities, POJOS, mappings, setters. . . All in the spirit of NATIVE SQL as anyone who hasn't been into ORB knows SQL. And mind you this is the very spirit in which HIBERNATE NATIVE SQL QUERY was implemented. Read your HIBERNATE DOCUMENT before quacking on your log. You quack! Yours truly, GAVIN KING's brother. Cheers!!!!