addressdao.java

来自「一个关于物流的管理系统」· Java 代码 · 共 65 行

JAVA
65
字号
package com.shunshi.ssh.dao;

import java.util.Collection;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.shunshi.ssh.entity.Address;
import com.shunshi.ssh.entity.User;

public class AddressDAO extends HibernateDaoSupport implements IAddressDAO {

	public void save(Address address) {
		try {
			getHibernateTemplate().saveOrUpdate(address);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(Address address) {
		try {
			getHibernateTemplate().delete(address);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public User findById(int id) {
		try {
			User user = (User) getHibernateTemplate().get(
					"com.shunshi.ssh.entity.Address", id);
			return user;
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Collection findByProperty(String propertyName, Object value) {
		try {
			String queryString = "from Address as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Collection findAll() {
		try {
			String queryString = "from Address";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void update(Address address) {
		try {
			getHibernateTemplate().saveOrUpdate(address);
		} catch (RuntimeException re) {
			throw re;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?