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

📄 persistencebrokerclinic.java

📁 spring,z几 塞积极 决撒 积极上经济歼击机就 将计就计经济年毫毫毫毫毫毫毫毫毫毫毫毫毫毫
💻 JAVA
字号:
package org.springframework.samples.petclinic.ojb;

import java.util.Collection;

import org.apache.ojb.broker.query.Criteria;
import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.query.QueryByCriteria;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport;
import org.springframework.samples.petclinic.Clinic;
import org.springframework.samples.petclinic.Owner;
import org.springframework.samples.petclinic.Pet;
import org.springframework.samples.petclinic.PetType;
import org.springframework.samples.petclinic.Vet;
import org.springframework.samples.petclinic.Visit;

/**
 * OJB PersistenceBroker implementation of the Clinic interface.
 *
 * <p>The mappings are defined in "OJB-repository.xml",
 * located in the root of the class path.
 *
 * @author Juergen Hoeller
 * @since 04.07.2004
 */
public class PersistenceBrokerClinic extends PersistenceBrokerDaoSupport implements Clinic {

	public Collection getVets() throws DataAccessException {
		QueryByCriteria query = new QueryByCriteria(Vet.class);
		query.addOrderByAscending("lastName");
		query.addOrderByAscending("firstName");
		return getPersistenceBrokerTemplate().getCollectionByQuery(query);
	}

	public Collection getPetTypes() throws DataAccessException {
		QueryByCriteria query = new QueryByCriteria(PetType.class);
		query.addOrderByAscending("name");
		return getPersistenceBrokerTemplate().getCollectionByQuery(query);
	}

	public Collection findOwners(String lastName) throws DataAccessException {
		Criteria criteria = new Criteria();
		criteria.addLike("lastName", lastName + "%");
		Query query = new QueryByCriteria(Owner.class, criteria);
		return getPersistenceBrokerTemplate().getCollectionByQuery(query);
	}

	public Owner loadOwner(int id) throws DataAccessException {
		return (Owner) getPersistenceBrokerTemplate().getObjectById(Owner.class, new Integer(id));
	}

	public Pet loadPet(int id) throws DataAccessException {
		return (Pet) getPersistenceBrokerTemplate().getObjectById(Pet.class, new Integer(id));
	}

	public void storeOwner(Owner owner) throws DataAccessException {
		getPersistenceBrokerTemplate().store(owner);
	}

	public void storePet(Pet pet) throws DataAccessException {
		getPersistenceBrokerTemplate().store(pet);
	}

	public void storeVisit(Visit visit) {
		getPersistenceBrokerTemplate().store(visit);
	}

}

⌨️ 快捷键说明

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