📄 persistencemanager.java
字号:
package cn.edu.nju.software.sd.torm;
import cn.edu.nju.software.sd.torm.cfg.Configuration;
import cn.edu.nju.software.sd.torm.PersistenceException;
public abstract class PersistenceManager {
protected static Configuration configuration = null;
private static PersistenceManager manager = null;
/**
* You must subclass the PersistenceManager to implement the abstract
* methods.
*
* @return the implementation of the PersistenceManager
*/
public static PersistenceManager getInstance() {
synchronized (PersistenceManager.class) {
if (manager == null) {
configuration = new Configuration().configure();
manager = configuration.createPersistenceManager();
}
}
return manager;
}
/**
* Delete the object from the database;
*
* @param obj
* object to be delete from the database;
* @throws PersistenceException
*/
public abstract void delete(Object obj) throws PersistenceException;
/**
* Insert a new object into the database, the persistence manager will
* generate the object identifier for the object.
*
* @param obj
* @throws PersistenceException
*/
public abstract void insert(Object obj) throws PersistenceException;
/**
* Update an object in the database
*
* @param obj
* @throws PersistenceException
*/
public abstract void update(Object obj) throws PersistenceException;
/**
* Given the class and the object-identifier, the object will be load from
* the database
*
* @param clazz
* the class of the object
* @param id
* the object-identifier of the object
* @return the object in the database
* @throws PersistenceException
*/
public abstract Object load(Class clazz, int id)
throws PersistenceException;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -