/** * Configures and provides access to Hibernate sessions, tied to the * current thread of execution. Follows the Thread Local Session * pattern, see {@link http://hibernate.org/42.html}. */ public class HibernateSessionFactory {
/** * Location of hibernate.cfg.xml file. * NOTICE: Location should be on the classpath as Hibernate uses * #resourceAsStream style lookup for its configuration file. That * is place the config file in a Java package - the default location * is the default Java package.<br><br> * Examples: <br> * <code>CONFIG_FILE_LOCATION = "/hibernate.conf.xml". * CONFIG_FILE_LOCATION = "/com/foo/bar/myhiberstuff.conf.xml".</code> */ private static String CONFIG_FILE_LOCATION = "/hibernate/hibernate.cfg.xml";
/** Holds a single instance of Session */ private static final ThreadLocal threadLocal = new ThreadLocal();
/** The single instance of hibernate configuration */ private static final Configuration cfg = new Configuration();
/** The single instance of hibernate SessionFactory */ private static org.hibernate.SessionFactory sessionFactory;
/** * Returns the ThreadLocal Session instance. Lazy initialize * the <code>SessionFactory</code> if needed. * * @return Session * @throws HibernateException */ public static Session currentSession() throws HibernateException { Session session = (Session) threadLocal.get();
} AbstractAdmin.java /* * WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized * by MyEclipse Hibernate tool integration. * * Created Fri Mar 24 14:48:52 GMT 2006 by MyEclipse Hibernate Tool. */ package mappingConfig;
import java.io.Serializable;
/** * A class that represents a row in the admin table. * You can customize the behavior of this class by editing the class, {@link Admin()}. * WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized * by MyEclipse Hibernate tool integration. */ public abstract class AbstractAdmin implements Serializable { /** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */ private int hashValue = 0;
/** The composite primary key value. */ private java.lang.Integer id;
/** The value of the simple name property. */ private java.lang.String name;
/** The value of the simple password property. */ private java.lang.String password;
/** The value of the simple telphone property. */ private java.lang.String telphone;
/** The value of the simple email property. */ private java.lang.String email;
/** The value of the simple sex property. */ private java.lang.String sex;
/** The value of the simple age property. */ private java.lang.String age;
/** * Simple constructor of AbstractAdmin instances. */ public AbstractAdmin() { }
/** * Constructor of AbstractAdmin instances given a simple primary key. * @param id */ public AbstractAdmin(java.lang.Integer id) { this.setId(id); }
/** * Return the simple primary key value that identifies this object. * @return java.lang.Integer */ public java.lang.Integer getId() { return id; }
/** * Set the simple primary key value that identifies this object. * @param id */ public void setId(java.lang.Integer id) { this.hashValue = 0; this.id = id; }
/** * Return the value of the name column. * @return java.lang.String */ public java.lang.String getName() { return this.name; }
/** * Set the value of the name column. * @param name */ public void setName(java.lang.String name) { this.name = name; }
/** * Return the value of the password column. * @return java.lang.String */ public java.lang.String getPassword() { return this.password; }
/** * Set the value of the password column. * @param password */ public void setPassword(java.lang.String password) { this.password = password; }
/** * Return the value of the telphone column. * @return java.lang.String */ public java.lang.String getTelphone() { return this.telphone; }
/** * Set the value of the telphone column. * @param telphone */ public void setTelphone(java.lang.String telphone) { this.telphone = telphone; }
/** * Return the value of the email column. * @return java.lang.String */ public java.lang.String getEmail() { return this.email; }
/** * Set the value of the email column. * @param email */ public void setEmail(java.lang.String email) { this.email = email; }
/** * Return the value of the sex column. * @return java.lang.String */ public java.lang.String getSex() { return this.sex; }
/** * Set the value of the sex column. * @param sex */ public void setSex(java.lang.String sex) { this.sex = sex; }
/** * Return the value of the age column. * @return java.lang.String */ public java.lang.String getAge() { return this.age; }
/** * Set the value of the age column. * @param age */ public void setAge(java.lang.String age) { this.age = age; }
/** * Implementation of the equals comparison on the basis of equality of the primary key values. * @param rhs * @return boolean */ public boolean equals(Object rhs) { if (rhs == null) return false; if (! (rhs instanceof Admin)) return false; Admin that = (Admin) rhs; if (this.getId() == null that.getId() == null) return false; return (this.getId().equals(that.getId())); }
/** * Implementation of the hashCode method conforming to the Bloch pattern with * the exception of array properties (these are very unlikely primary key types). * @return int */ public int hashCode() { if (this.hashValue == 0) { int result = 17; int idValue = this.getId() == null ? 0 : this.getId().hashCode(); result = result * 37 + idValue; this.hashValue = result; } return this.hashValue; } } Admin.java /* * Created Fri Mar 24 14:31:50 GMT 2006 by MyEclipse Hibernate Tool. */ package mappingConfig;
import java.io.Serializable;
/** * A class that represents a row in the 'admin' table. * This class may be customized as it is never re-generated * after being created. */ public class Admin extends AbstractAdmin implements Serializable { /** * Simple constructor of Admin instances. */ public Admin() { }
/** * Constructor of Admin instances given a simple primary key. * @param id */ public Admin(java.lang.Integer id) { super(id); }
<!-- DO NOT EDIT: This is a generated file that is synchronized --> <!-- by MyEclipse Hibernate tool integration. --> <!-- Created Fri Mar 24 14:48:52 GMT 2006 --> <hibernate-mapping package="mappingConfig">