Package com.vst.dao.hibernate

Source Code of com.vst.dao.hibernate.ObjectPhotoDaoHibernate

package com.vst.dao.hibernate;

import com.vst.dao.ObjectPhotoDao;
import com.vst.model.BuildingObject;
import com.vst.model.ObjectPhoto;
import org.springframework.orm.ObjectRetrievalFailureException;

import java.util.List;

public class ObjectPhotoDaoHibernate extends BaseDaoHibernate<ObjectPhoto> implements ObjectPhotoDao {

  //TODO rename this method
        public List getObjectPhotos(String objectId) {
            BuildingObject buildingObject=(BuildingObject)super.getSession().get(BuildingObject.class,new Integer(objectId));
            return buildingObject.getPhotoes();

        /* Remove the line above and uncomment this code block if you want
           to use Hibernate's Query by Example API.
        if (objectPhoto == null) {
            return getHibernateTemplate().find("from ObjectPhoto");
        } else {
            // filter on properties set in the objectPhoto
            HibernateCallback callback = new HibernateCallback() {
                public Object doInHibernate(Session session) throws HibernateException {
                    Example ex = Example.create(objectPhoto).ignoreCase().enableLike(MatchMode.ANYWHERE);
                    return session.createCriteria(ObjectPhoto.class).add(ex).list();
                }
            };
            return (List) getHibernateTemplate().execute(callback);
        }*/
    }

    /**
     * @see com.vst.dao.ObjectPhotoDao#getObjectPhoto(Integer photoId)
     */
    public ObjectPhoto getObjectPhoto(final Integer photoId) {
        ObjectPhoto objectPhoto = (ObjectPhoto) getObject(photoId);
        return objectPhoto;
    }

    /**
     * @see com.vst.dao.ObjectPhotoDao#saveObjectPhoto(ObjectPhoto objectPhoto)
     */
    public void saveObjectPhoto(final ObjectPhoto objectPhoto) {
        saveObject(objectPhoto);
    }

    /**
     * @see com.vst.dao.ObjectPhotoDao#removeObjectPhoto(Integer photoId)
     */
    public void removeObjectPhoto(final Integer photoId) {
        removeObject(photoId);
    }

  @Override
  Class<ObjectPhoto> getServiceClass() {
    return ObjectPhoto.class;
  }
}
TOP

Related Classes of com.vst.dao.hibernate.ObjectPhotoDaoHibernate

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.