⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addressdao.java

📁 一个关于物流的管理系统
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -