|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.wpi.prc.persistence.HibernateController
public class HibernateController
The HibernateController class controls access to important Hibernate functions.
Field Summary | |
---|---|
private org.hibernate.cfg.Configuration |
config
|
private DatabaseType |
dbType
|
private static HibernateController |
hibernateController
|
private java.util.Properties |
hibernateProperties
|
private boolean |
isConfigured
|
private org.hibernate.SessionFactory |
sessions
|
Constructor Summary | |
---|---|
private |
HibernateController()
Private constructor prevents direct instantiation of this class. |
Method Summary | |
---|---|
org.hibernate.Session |
createSession()
Creates a new Hibernate session to use for database access. |
void |
exportSchema()
Exports the schema to the database. |
java.util.Properties |
getHibernateProperties()
|
void |
initialize()
Initializes hibernate. |
void |
initialize(DatabaseType db)
Initializes hibernate with the specified Hibernate configuration file. |
void |
initialize(java.lang.String configFilePath)
Initializes hibernate using an alternate project configuration file path. |
void |
initializeForUnitTests()
Initializes Hibernate for use with the JUnit tests. |
static HibernateController |
instance()
|
boolean |
isConfigured()
|
private java.util.Properties |
readConfigFromFile()
Reads project configuration from the project properties file, then translates it into Hibernate properties. |
private java.util.Properties |
readConfigFromFile(java.lang.String configFilePath)
Reads project configuration from the project properties file, then translates it into Hibernate properties. |
private java.util.Properties |
readProjectProperties(Project proj)
Configures Hibernate by inspecting a project. |
private void |
setConfiguration()
Sets the Hibernate configuration that was extracted from the project. |
void |
setDatabaseType(DatabaseType db)
Sets the type of database hibernate will use if none is specified. |
void |
setHibernateProperties(java.util.Properties hibernateProperties)
|
void |
shutdown()
Shuts down Hibernate and closes all open sessions. |
void |
updateSchema()
Updates the database schema. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static HibernateController hibernateController
private DatabaseType dbType
private java.util.Properties hibernateProperties
private org.hibernate.cfg.Configuration config
private org.hibernate.SessionFactory sessions
private boolean isConfigured
Constructor Detail |
---|
private HibernateController()
Method Detail |
---|
public java.util.Properties getHibernateProperties()
public void setHibernateProperties(java.util.Properties hibernateProperties)
hibernateProperties
- The hibernateProperties to set.private java.util.Properties readConfigFromFile() throws MissingConfigurationFileException
MissingConfigurationFileException
private java.util.Properties readConfigFromFile(java.lang.String configFilePath) throws MissingConfigurationFileException
configFilePath
- to the project configuration file.
MissingConfigurationFileException
private java.util.Properties readProjectProperties(Project proj)
proj
- The project to use to configure Hibernate.
public void setDatabaseType(DatabaseType db)
db
- The default database type to set.public void initialize(DatabaseType db) throws MissingConfigurationFileException, org.hibernate.HibernateException
db
- The type of database to use.
MissingConfigurationFileException
org.hibernate.HibernateException
public void initialize(java.lang.String configFilePath) throws MissingConfigurationFileException, org.hibernate.HibernateException
configFilePath
- Path to the project configuration file.
MissingConfigurationFileException
org.hibernate.HibernateException
public void initialize() throws MissingConfigurationFileException, org.hibernate.HibernateException
MissingConfigurationFileException
org.hibernate.HibernateException
public boolean isConfigured()
private void setConfiguration() throws org.hibernate.HibernateException
org.hibernate.HibernateException
public void initializeForUnitTests()
public org.hibernate.Session createSession()
public void exportSchema() throws org.hibernate.HibernateException
org.hibernate.HibernateException
public void updateSchema() throws org.hibernate.HibernateException
org.hibernate.HibernateException
public void shutdown()
public static HibernateController instance()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |