當前位置: 首頁>>代碼示例>>Java>>正文


Java PetType類代碼示例

本文整理匯總了Java中org.springframework.samples.petclinic.PetType的典型用法代碼示例。如果您正苦於以下問題:Java PetType類的具體用法?Java PetType怎麽用?Java PetType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PetType類屬於org.springframework.samples.petclinic包,在下文中一共展示了PetType類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadPet

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
@Transactional(readOnly = true)
public Pet loadPet(int id) throws DataAccessException {
	JdbcPet pet;
	try {
		pet = this.simpleJdbcTemplate.queryForObject(
				"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE id=?",
				new JdbcPetRowMapper(),
				id);
	}
	catch (EmptyResultDataAccessException ex) {
		throw new ObjectRetrievalFailureException(Pet.class, new Integer(id));
	}
	Owner owner = loadOwner(pet.getOwnerId());
	owner.addPet(pet);
	pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
	loadVisits(pet);
	return pet;
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:19,代碼來源:SimpleJdbcClinic.java

示例2: setAsText

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
@Override
public void setAsText(String text) throws IllegalArgumentException {
	for (PetType type : this.clinic.getPetTypes()) {
		if (type.getName().equals(text)) {
			setValue(type);
		}
	}
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:9,代碼來源:PetTypeEditor.java

示例3: initBinder

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
public void initBinder(WebDataBinder binder, WebRequest request) {
	SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	dateFormat.setLenient(false);
	binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
	binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
	binder.registerCustomEditor(PetType.class, new PetTypeEditor(this.clinic));
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:8,代碼來源:ClinicBindingInitializer.java

示例4: loadPetsAndVisits

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
/**
 * Loads the {@link Pet} and {@link Visit} data for the supplied
 * {@link Owner}.
 */
private void loadPetsAndVisits(final Owner owner) {
	final List<JdbcPet> pets = this.simpleJdbcTemplate.query(
			"SELECT id, name, birth_date, type_id, owner_id FROM pets WHERE owner_id=?",
			new JdbcPetRowMapper(),
			owner.getId().intValue());
	for (JdbcPet pet : pets) {
		owner.addPet(pet);
		pet.setType(EntityUtils.getById(getPetTypes(), PetType.class, pet.getTypeId()));
		loadVisits(pet);
	}
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:16,代碼來源:SimpleJdbcClinic.java

示例5: testGetPetTypes

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
public void testGetPetTypes() {
	Collection<PetType> petTypes = this.clinic.getPetTypes();
	assertEquals("JDBC query must show the same number of pet types", super.countRowsInTable("TYPES"),
			petTypes.size());
	PetType t1 = EntityUtils.getById(petTypes, PetType.class, 1);
	assertEquals("cat", t1.getName());
	PetType t4 = EntityUtils.getById(petTypes, PetType.class, 4);
	assertEquals("snake", t4.getName());
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:10,代碼來源:AbstractJpaClinicTests.java

示例6: testLoadPet

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
public void testLoadPet() {
	Collection<PetType> types = this.clinic.getPetTypes();
	Pet p7 = this.clinic.loadPet(7);
	assertTrue(p7.getName().startsWith("Samantha"));
	assertEquals(EntityUtils.getById(types, PetType.class, 1).getId(), p7.getType().getId());
	assertEquals("Jean", p7.getOwner().getFirstName());
	Pet p6 = this.clinic.loadPet(6);
	assertEquals("George", p6.getName());
	assertEquals(EntityUtils.getById(types, PetType.class, 4).getId(), p6.getType().getId());
	assertEquals("Peter", p6.getOwner().getFirstName());
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:12,代碼來源:AbstractJpaClinicTests.java

示例7: testInsertPet

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
public void testInsertPet() {
	Owner o6 = this.clinic.loadOwner(6);
	int found = o6.getPets().size();
	Pet pet = new Pet();
	pet.setName("bowser");
	Collection<PetType> types = this.clinic.getPetTypes();
	pet.setType(EntityUtils.getById(types, PetType.class, 2));
	pet.setBirthDate(new Date());
	o6.addPet(pet);
	assertEquals(found + 1, o6.getPets().size());
	this.clinic.storeOwner(o6);
	// assertTrue(!pet.isNew()); -- NOT TRUE FOR TOPLINK (before commit)
	o6 = this.clinic.loadOwner(6);
	assertEquals(found + 1, o6.getPets().size());
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:16,代碼來源:AbstractJpaClinicTests.java

示例8: afterPropertiesSet

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
public void afterPropertiesSet() throws Exception {
    Assert.notNull(clinic, "Clinic must be provided.");
    petTypes = new LinkedHashMap();
    for (Iterator i = clinic.getPetTypes().iterator(); i.hasNext();) {
        PetType petType = (PetType)i.next();
        petTypes.put(petType.getName(), petType);
    }
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:9,代碼來源:PetTypeBinder.java

示例9: PetTypeAdapter

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
private PetTypeAdapter(ValueModel valueModel, final Map petTypes) {
    super(valueModel, new Closure() {
        public Object call(Object petType) {                    
            return petType != null ? ((PetType)petType).getName() : "";
        }
    }, new Closure() {
        public Object call(Object petTypeName) {
            return petTypes.get(petTypeName);
        }
    });            
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:12,代碼來源:PetTypeBinder.java

示例10: populatePetTypes

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
@ModelAttribute("types")
public Collection<PetType> populatePetTypes() {
	return this.clinic.getPetTypes();
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:5,代碼來源:AddPetForm.java

示例11: getPetTypes

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public Collection<PetType> getPetTypes() {
	return this.em.createQuery("SELECT ptype FROM PetType ptype ORDER BY ptype.name").getResultList();
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:6,代碼來源:EntityManagerClinic.java

示例12: getPetTypes

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
@Transactional(readOnly = true)
public Collection<PetType> getPetTypes() throws DataAccessException {
	return this.simpleJdbcTemplate.query(
			"SELECT id, name FROM types ORDER BY name",
			ParameterizedBeanPropertyRowMapper.newInstance(PetType.class));
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:7,代碼來源:SimpleJdbcClinic.java

示例13: getPetTypes

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public Collection<PetType> getPetTypes() {
	return sessionFactory.getCurrentSession().createQuery("from PetType type order by type.name").list();
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:6,代碼來源:HibernateClinic.java

示例14: PetTypeBinder

import org.springframework.samples.petclinic.PetType; //導入依賴的package包/類
public PetTypeBinder() {
    super(PetType.class, new String[] {});        
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:4,代碼來源:PetTypeBinder.java


注:本文中的org.springframework.samples.petclinic.PetType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。