📄 receiveaddressdao.java
字号:
package tarena.dao;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Example;
import tarena.entity.Receiveaddress;
@SuppressWarnings("unchecked")
public class ReceiveaddressDAO extends BaseHibernateDAO {
public static final String ISUSERDEL = "isuserdel";
public static final String RECEIVENAME = "receivename";
public static final String PROVINCE = "province";
public static final String CITY = "city";
public static final String AREA = "area";
public static final String ADDRESS = "address";
public static final String ZIP = "zip";
public static final String PHONE = "phone";
public static final String MOBILE = "mobile";
public void save(Receiveaddress transientInstance) {
Session session = getSession();
try {
session.beginTransaction().begin();
session.saveOrUpdate(transientInstance);
session.getTransaction().commit();
} catch (RuntimeException re) {
session.getTransaction().rollback();
throw re;
} finally{
closeSession();
}
}
public void delete(Receiveaddress persistentInstance) {
Session session = getSession();
try {
session.beginTransaction().begin();
getSession().delete(persistentInstance);
session.getTransaction().commit();
} catch (RuntimeException re){
session.getTransaction().rollback();
throw re;
} finally{
closeSession();
}
}
public Receiveaddress findById(java.lang.Integer id) {
Session session = getSession();
try {
Receiveaddress instance = (Receiveaddress) session.get(
"tarena.entity.Receiveaddress", id);
return instance;
} catch (RuntimeException re) {
return null;
}finally{
closeSession();
}
}
public List<Receiveaddress> findByExample(Receiveaddress instance) {
try {
List results = getSession().createCriteria(
"tarena.entity.Receiveaddress").add(
Example.create(instance)).list();
return results;
} catch (RuntimeException re) {
throw re;
} finally {
closeSession();
}
}
public List<Receiveaddress> findByProperty(String propertyName, Object value) {
try {
String queryString = "from Receiveaddress as model where model."
+ propertyName + "= ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
throw re;
} finally {
closeSession();
}
}
public List<Receiveaddress> findByIsuserdel(Object isuserdel) {
return findByProperty(ISUSERDEL, isuserdel);
}
public List<Receiveaddress> findByReceivename(Object receivename) {
return findByProperty(RECEIVENAME, receivename);
}
public List<Receiveaddress> findByProvince(Object province) {
return findByProperty(PROVINCE, province);
}
public List<Receiveaddress> findByCity(Object city) {
return findByProperty(CITY, city);
}
public List<Receiveaddress> findByArea(Object area) {
return findByProperty(AREA, area);
}
public List<Receiveaddress> findByAddress(Object address) {
return findByProperty(ADDRESS, address);
}
public List<Receiveaddress> findByZip(Object zip) {
return findByProperty(ZIP, zip);
}
public List<Receiveaddress> findByPhone(Object phone) {
return findByProperty(PHONE, phone);
}
public List<Receiveaddress> findByMobile(Object mobile) {
return findByProperty(MOBILE, mobile);
}
public List<Receiveaddress> findAll() {
try {
String queryString = "from Receiveaddress";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
throw re;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -