Skip to content

Instantly share code, notes, and snippets.

View yusufcakmak's full-sized avatar
🏠
Working from home

Yusuf Cakmak yusufcakmak

🏠
Working from home
View GitHub Profile
<!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>
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;
@yusufcakmak
yusufcakmak / pom.xml
Created November 11, 2015 20:48
pom.xml for thymeleaf
<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>
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;
public void deleteBook(Book book) {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.delete(book);
session.getTransaction().commit();
}
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());
}
public void updateBook(Book book){
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.merge(book);
session.getTransaction();
}
@yusufcakmak
yusufcakmak / Create
Last active August 29, 2015 14:26
HibernateCRUDExample
public void saveBook(Book book) {
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.save(book);
session.getTransaction().commit();
}
@yusufcakmak
yusufcakmak / Book.java
Created August 4, 2015 13:24
HibernateCRUDExample
package co.mobiwise.hibernate.model;
import javax.annotation.Generated;
import javax.persistence.*;
/**
* Created by yusufcakmak on 8/4/15.
*/
@Entity
@Table(name="book")
@yusufcakmak
yusufcakmak / HibernateUtil.java
Created August 4, 2015 13:19
HibernateCRUDExample
package co.mobiwise.hibernate.util;
/**
* Created by yusufcakmak on 8/4/15.
*/
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {