1 package org.objectweb.petals.demo.icare.dao.hibernate; 2 3 import java.util.Collection ; 4 5 import org.objectweb.petals.demo.icare.dao.CarDao; 6 import org.objectweb.petals.demo.icare.model.Car; 7 import org.objectweb.petals.demo.icare.model.Category; 8 import org.objectweb.petals.demo.icare.model.Entity; 9 import org.objectweb.petals.demo.icare.model.Reservation; 10 import org.springframework.orm.hibernate3.support.HibernateDaoSupport; 11 12 20 public class CarHibernateDao extends HibernateDaoSupport implements CarDao { 21 22 @SuppressWarnings ("unchecked") 23 public Collection <Car> loadAllCars() { 24 return getHibernateTemplate().find("from Car"); 25 } 26 27 public void storeEntity(Entity e) { 28 getHibernateTemplate().saveOrUpdate(e); 29 } 30 31 public Entity getEntityById(Class clazz, long id) { 32 return (Entity) getHibernateTemplate().get(clazz, id); 33 } 34 35 public void storeAllCategories(Collection <Category> list) { 36 getHibernateTemplate().saveOrUpdateAll(list); 37 } 38 39 public void storeAllCars(Collection <Car> list) { 40 getHibernateTemplate().saveOrUpdateAll(list); 41 } 42 43 @SuppressWarnings ("unchecked") 44 public Collection <Category> loadAllCategories() { 45 return getHibernateTemplate().find("from Category"); 46 } 47 48 public void storeAllReservation(Collection <Reservation> list) { 49 getHibernateTemplate().saveOrUpdateAll(list); 50 51 } 52 53 public Collection <Reservation> loadAllReservations() { 54 return getHibernateTemplate().find("from Reservation"); 55 } 56 } 57 | Popular Tags |