Note that there are some explanatory texts on larger screens.

plurals
  1. POAPI or code : Difference between Hibernate 3 and 4?
    primarykey
    data
    text
    <p>I have pasted <strong>Hibernate 3</strong> configuration file , SessionFactory class to configure this config.xml and a bean with JPA annotations. I want to know if I were using <strong>Hibernate 4</strong> then what would have been the changes in the context at code level or very broad differences or advancements in layman language.</p> <blockquote> <p>hibernate.cfg.xml</p> </blockquote> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt; &lt;hibernate-configuration&gt; &lt;session-factory&gt; &lt;property name="hibernate.connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt; &lt;property name="hibernate.connection.url"&gt;jdbc:oracle:thin:@192.168.2.144:1521:xe&lt;/property&gt; &lt;property name="hibernate.connection.username"&gt;prateek&lt;/property&gt; &lt;property name="connection.password"&gt;prateek&lt;/property&gt; &lt;property name="connection.pool_size"&gt;1&lt;/property&gt; &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/property&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt; &lt;mapping class="com.vaannila.domain.User1" /&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt; </code></pre> <blockquote> <p>Static java class to establish connection (SessionFactory Helper)</p> </blockquote> <pre><code>import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class SessionFactoryHelper { private static final SessionFactory sessionFactory; static { try { /* * Build a SessionFactory object from session-factory configuration * defined in the hibernate.cfg.xml file. In this file we register * the JDBC connection information, connection pool, the hibernate * dialect that we used and the mapping to our hbm.xml file for each * POJO (Plain Old Java Object). * */ sessionFactory = new Configuration().configure().buildSessionFactory(); } catch (Throwable e) { System.err.println("Error in creating SessionFactory object." + e.getMessage()); throw new ExceptionInInitializerError(e); } } /* * A static method for other application to get SessionFactory object * initialized in this helper class. * */ public static SessionFactory getSessionFactory() { return sessionFactory; } } </code></pre> <blockquote> <p>Bean class</p> </blockquote> <pre><code>import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name="USER1") public class User1 { private Long id; private String name; private String gender; private String country; private String aboutYou; private Boolean mailingList; @Id @GeneratedValue @Column(name="USER_ID") public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column(name="USER_NAME") public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name="USER_GENDER") public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } @Column(name="USER_COUNTRY") public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } @Column(name="USER_ABOUT_YOU") public String getAboutYou() { return aboutYou; } public void setAboutYou(String aboutYou) { this.aboutYou = aboutYou; } @Column(name="USER_MAILING_LIST") public Boolean getMailingList() { return mailingList; } public void setMailingList(Boolean mailingList) { this.mailingList = mailingList; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload