// 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: chapter09/src/main/java/com/packtpub/pf/blueprint/persistence/entity/Profile.java
// @Entity
// @Table
// @Data
// public class Profile implements java.io.Serializable {
// 
//     @Id
//     @GeneratedValue
//     private Long id;
// 
//     private String firstName;
// 
//     private String lastName;
// 
//     @Column(unique = true)
//     private String email;
//     private String password;
// 
//     @Temporal(TemporalType.DATE)
//     private Date dateOfBirth;
// 
//     private String gender;
// 
//     private String aboutme;
// 
//     private String avatar = "no_image_available";
// 
//     private String currentLocation;
// 
//     private boolean verified;
// 
//     @Temporal(TemporalType.DATE)
//     private Date createDate;
// 
//     @OneToMany(mappedBy = "user")
//     private Set<Comment> comments = new HashSet<>();
// 
//     @OneToMany(mappedBy = "user")
//     private Set<UserPost> posts = new HashSet<>();
// 
//     @ManyToMany
//     @JoinTable(name="tbl_friends",
//             joinColumns=@JoinColumn(name="personId"),
//             inverseJoinColumns=@JoinColumn(name="friendId")
//     )
//     private List<Profile> friends;
// 
//     @ManyToMany
//     @JoinTable(name="tbl_friends",
//             joinColumns=@JoinColumn(name="friendId"),
//             inverseJoinColumns=@JoinColumn(name="personId")
//     )
//     private List<Profile> friendOf;
// 
// }


import com.packtpub.pf.blueprint.persistence.HibernateUtil;
import com.packtpub.pf.blueprint.persistence.entity.Profile;
import org.hibernate.Session;
import java.util.Date;
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: chapter09/src/main/java/com/packtpub/pf/blueprint/persistence/entity/Profile.java
// @Entity
// @Table
// @Data
// public class Profile implements java.io.Serializable {
// 
//     @Id
//     @GeneratedValue
//     private Long id;
// 
//     private String firstName;
// 
//     private String lastName;
// 
//     @Column(unique = true)
//     private String email;
//     private String password;
// 
//     @Temporal(TemporalType.DATE)
//     private Date dateOfBirth;
// 
//     private String gender;
// 
//     private String aboutme;
// 
//     private String avatar = "no_image_available";
// 
//     private String currentLocation;
// 
//     private boolean verified;
// 
//     @Temporal(TemporalType.DATE)
//     private Date createDate;
// 
//     @OneToMany(mappedBy = "user")
//     private Set<Comment> comments = new HashSet<>();
// 
//     @OneToMany(mappedBy = "user")
//     private Set<UserPost> posts = new HashSet<>();
// 
//     @ManyToMany
//     @JoinTable(name="tbl_friends",
//             joinColumns=@JoinColumn(name="personId"),
//             inverseJoinColumns=@JoinColumn(name="friendId")
//     )
//     private List<Profile> friends;
// 
//     @ManyToMany
//     @JoinTable(name="tbl_friends",
//             joinColumns=@JoinColumn(name="friendId"),
//             inverseJoinColumns=@JoinColumn(name="personId")
//     )
//     private List<Profile> friendOf;
// 
// }


// Path: chapter09/src/test/java/com/pocketpub/pfbp/test/HibernateUtilTest.java
import com.packtpub.pf.blueprint.persistence.HibernateUtil;
import com.packtpub.pf.blueprint.persistence.entity.Profile;
import org.hibernate.Session;
import java.util.Date;
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();
        Profile u = new Profile();