This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" | |
| xmlns:th="http://www.thymeleaf.org"> | |
| <head> | |
| <meta charset="utf-8"/> | |
| <title>Hello World Thymeleaf!!</title> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
| </head> | |
| <body> | |
| <p th:text="#{hello}">Hello World Thymeleaf Offline!!</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package co.mobiwise.thymeleaf; | |
| /** | |
| * Created by yusuf on 11/11/15. | |
| */ | |
| import java.io.IOException; | |
| import javax.servlet.ServletException; | |
| import javax.servlet.http.HttpServlet; | |
| import javax.servlet.http.HttpServletRequest; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| <modelVersion>4.0.0</modelVersion> | |
| <groupId>co.mobiwise</groupId> | |
| <artifactId>thymeleaf</artifactId> | |
| <version>1.0-SNAPSHOT</version> | |
| <packaging>jar</packaging> | |
| <name>thymeleaf</name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package co.mobiwise.hibernate.app; | |
| import co.mobiwise.hibernate.model.Book; | |
| import co.mobiwise.hibernate.util.HibernateUtil; | |
| import org.hibernate.Criteria; | |
| import org.hibernate.Session; | |
| import org.hibernate.SessionFactory; | |
| import org.hibernate.Transaction; | |
| import org.hibernate.criterion.Order; | |
| import org.hibernate.criterion.Projections; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void deleteBook(Book book) { | |
| Session session = HibernateUtil.getSessionFactory().openSession(); | |
| session.beginTransaction(); | |
| session.delete(book); | |
| session.getTransaction().commit(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void getBook() { | |
| Session session = HibernateUtil.getSessionFactory().openSession(); | |
| session.beginTransaction(); | |
| ArrayList<Book> bookList = (ArrayList<Book>) session.createQuery("from Book").list(); | |
| if(bookList !=null){ | |
| for (int i = 0; i < bookList.size(); i++) { | |
| System.out.println("Book Name : " + bookList.get(i).getBookName()); | |
| System.out.println("Book Desc : " + bookList.get(i).getBookDesc()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void updateBook(Book book){ | |
| Session session = HibernateUtil.getSessionFactory().openSession(); | |
| session.beginTransaction(); | |
| session.merge(book); | |
| session.getTransaction(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void saveBook(Book book) { | |
| Session session = HibernateUtil.getSessionFactory().openSession(); | |
| session.beginTransaction(); | |
| session.save(book); | |
| session.getTransaction().commit(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package co.mobiwise.hibernate.model; | |
| import javax.annotation.Generated; | |
| import javax.persistence.*; | |
| /** | |
| * Created by yusufcakmak on 8/4/15. | |
| */ | |
| @Entity | |
| @Table(name="book") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package co.mobiwise.hibernate.util; | |
| /** | |
| * Created by yusufcakmak on 8/4/15. | |
| */ | |
| import org.hibernate.SessionFactory; | |
| import org.hibernate.cfg.Configuration; | |
| public class HibernateUtil { |