1. Install Mqsldb, Mysql workbench(for the Mysql client), and execute the below query to create table inside your database

CREATE TABLE `codinkodb1stock`.`stock` (
`STOCK_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`STOCK_CODE` varchar(10) NOT NULL,
`STOCK_NAME` varchar(20) NOT NULL,
PRIMARY KEY (`STOCK_ID`) USING BTREE,
UNIQUE KEY `UNI_STOCK_NAME` (`STOCK_NAME`),
UNIQUE KEY `UNI_STOCK_ID` (`STOCK_CODE`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8;

2. Clone the project from here, and run as java application.

https://github.com/codinko/springhibernatetemplate1.git

3. See output below

Hibernate: insert into codinkodb1.stock (STOCK_CODE, STOCK_NAME) values (?, ?)

Hibernate: select stock0_.STOCK_ID as STOCK1_0_, stock0_.STOCK_CODE as STOCK2_0_, stock0_.STOCK_NAME as STOCK3_0_ from codinkodb1.stock stock0_ where stock0_.STOCK_CODE=?

Stock [stockId=1, stockCode=1001, stockName=IPAD-MINI]

Hibernate: update codinkodb1.stock set STOCK_CODE=?, STOCK_NAME=? where STOCK_ID=?

Done


main reference to try out in local , create git proj and after its working, push to repo:

  • https://www.mkyong.com/spring/maven-spring-hibernate-mysql-example/

//TODO

Next goal is to use HibernateSession and try session.save/txn.commit etc

  • http://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate
  • https://stackoverflow.com/questions/912659/what-is-the-proper-way-to-re-attach-detached-objects-in-hibernate

blogs to try out  later:

  • http://websystique.com/springmvc/spring-4-mvc-and-hibernate4-integration-example-using-annotations/
  • https://www.journaldev.com/3524/spring-hibernate-integration-example-tutorial
  • https://www.journaldev.com/3531/spring-mvc-hibernate-mysql-integration-crud-example-tutorial

github reference to tryout later:

  • https://github.com/cavalr/Spring3Hibernate4/blob/master/src/main/java/com/blog/cavalr/controller/UserController.java
  • https://github.com/hantsy/angularjs-springmvc-sample
  • https://github.com/shagstrom/spring-mvc-hibernate-skeleton/blob/master/src/main/java/com/dreamchain/skeleton/web/UserController.java
  • https://github.com/callicoder/spring-boot-mysql-rest-api-tutorial