// Path: chapter09/src/main/java/com/packtpub/pf/blueprint/persistence/HibernateUtil.java
// public class HibernateUtil {
// 
//     private static final SessionFactory sessionFactory = buildSessionFactory();
// 
//     private static SessionFactory buildSessionFactory() throws HibernateException {
//         Configuration configuration = new Configuration().configure();
//         // configures settings from hibernate.cfg.xml
// 
//         StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();
// 
//         // If you miss the below line then it will complain about a missing dialect setting
//         serviceRegistryBuilder.applySettings(configuration.getProperties());
// 
//         ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();
//         return configuration.buildSessionFactory(serviceRegistry);
//     }
// 
//     public static SessionFactory getSessionFactory() {
//         return sessionFactory;
//     }
// 
//     public static void shutdown() {
//         // Close caches and connection pools
//         getSessionFactory().close();
//     }
// 
// }
// 
// Path: chapter07/src/main/java/com/packtpub/pf/blueprint/persistence/entity/Movie.java
// @Entity
// @Table
// @Data
// public class Movie {
// 
//     @Id
//     @GeneratedValue
//     private Long id;
// 
//     private String title;
// 
//     private String description;
// 
//     @Temporal(TemporalType.DATE)
//     private Date releaseDate;
// 
//     private int rating;
// 
//     private boolean favorite;
// 
//     private String image;
// 
//     private boolean isImageUrl;
// 
//     private String movieUrl;
// 
//     private MovieType movieType;
// 
//     private boolean isPublic;
// 
//     @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
//     @JoinTable(name = "MOVIE_TAGS",
//             joinColumns = {@JoinColumn(name = "MOVIE_ID")},
//             inverseJoinColumns = {@JoinColumn(name = "TAG_ID")})
//     private Set<Tags> tags = new HashSet<>();
// 
//     @OneToMany(mappedBy = "movie", fetch = FetchType.LAZY)
//     private Set<Comment> comments = new HashSet<>();
// 
//     @ManyToOne
//     private User user;
// 
// 
//     public void addToTags(Tags t){
//          this.tags.add(t);
//     }
// 
// 
// }


import com.packtpub.pf.blueprint.persistence.HibernateUtil;
import com.packtpub.pf.blueprint.persistence.entity.Movie;
import org.hibernate.Session;
import java.util.List;
package com.pocketpub.pfbp.test;



/**
 * Created with IntelliJ IDEA.
 * User: psramkumar
 * Date: 2/6/14
 * Time: 7:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class HibernateUtilTest {

    public static void main(String[] args) {
        System.out.println("Testing Hibernate Utility Class");
        Session session = HibernateUtil.getSessionFactory().openSession();

        session.beginTransaction();
// Path: chapter09/src/main/java/com/packtpub/pf/blueprint/persistence/HibernateUtil.java
// public class HibernateUtil {
// 
//     private static final SessionFactory sessionFactory = buildSessionFactory();
// 
//     private static SessionFactory buildSessionFactory() throws HibernateException {
//         Configuration configuration = new Configuration().configure();
//         // configures settings from hibernate.cfg.xml
// 
//         StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();
// 
//         // If you miss the below line then it will complain about a missing dialect setting
//         serviceRegistryBuilder.applySettings(configuration.getProperties());
// 
//         ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();
//         return configuration.buildSessionFactory(serviceRegistry);
//     }
// 
//     public static SessionFactory getSessionFactory() {
//         return sessionFactory;
//     }
// 
//     public static void shutdown() {
//         // Close caches and connection pools
//         getSessionFactory().close();
//     }
// 
// }
// 
// Path: chapter07/src/main/java/com/packtpub/pf/blueprint/persistence/entity/Movie.java
// @Entity
// @Table
// @Data
// public class Movie {
// 
//     @Id
//     @GeneratedValue
//     private Long id;
// 
//     private String title;
// 
//     private String description;
// 
//     @Temporal(TemporalType.DATE)
//     private Date releaseDate;
// 
//     private int rating;
// 
//     private boolean favorite;
// 
//     private String image;
// 
//     private boolean isImageUrl;
// 
//     private String movieUrl;
// 
//     private MovieType movieType;
// 
//     private boolean isPublic;
// 
//     @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
//     @JoinTable(name = "MOVIE_TAGS",
//             joinColumns = {@JoinColumn(name = "MOVIE_ID")},
//             inverseJoinColumns = {@JoinColumn(name = "TAG_ID")})
//     private Set<Tags> tags = new HashSet<>();
// 
//     @OneToMany(mappedBy = "movie", fetch = FetchType.LAZY)
//     private Set<Comment> comments = new HashSet<>();
// 
//     @ManyToOne
//     private User user;
// 
// 
//     public void addToTags(Tags t){
//          this.tags.add(t);
//     }
// 
// 
// }


// Path: chapter07/src/test/java/com/pocketpub/pfbp/test/HibernateUtilTest.java
import com.packtpub.pf.blueprint.persistence.HibernateUtil;
import com.packtpub.pf.blueprint.persistence.entity.Movie;
import org.hibernate.Session;
import java.util.List;

package com.pocketpub.pfbp.test;



/**
 * Created with IntelliJ IDEA.
 * User: psramkumar
 * Date: 2/6/14
 * Time: 7:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class HibernateUtilTest {

    public static void main(String[] args) {
        System.out.println("Testing Hibernate Utility Class");
        Session session = HibernateUtil.getSessionFactory().openSession();

        session.beginTransaction();
        Movie cat = new Movie();