Java-java-com-util-common-service:crudservice.java

Source: Internet
Author: User

Ylbtech-java-java-com-util-common-service:crudservice.java

1. back to top
1.
 PackageCom.shineyoo.manager.util.common.service;Importjava.util.Collection;Importjava.util.List;Importorg.springframework.beans.factory.annotation.Autowired;Importorg.springframework.transaction.annotation.Transactional;ImportCom.shineyoo.manager.util.common.persistence.CrudDao;Importcom.shineyoo.manager.util.common.persistence.DataEntity;ImportCom.shineyoo.manager.util.common.persistence.Page;/*** Service base class *@author * @version2014-05-16*/@Transactional (readOnly=true) Public Abstract classCrudservice<dextendsCruddao<t>, TextendsDataentity<t>>extendsBaseservice {/*** Persistent Layer object*/@AutowiredprotectedD DAO; /*** Get A single piece of data *@paramID *@return     */     PublicT get (String ID) {returndao.get (ID); }        /*** Get A single piece of data *@paramEntity *@return     */     Publict get (t entity) {returnDao.get (entity); }    /*** Get A single piece of data *@paramEntity *@return     */     PublicT getnew (t entity) {returndao.getnew (entity); }    /*** Query list data *@paramEntity *@return     */     PublicList<t>findlist (T entity) {returndao.findlist (entity); }    /*** Query list data *@paramEntity *@return     */     PublicList<t>findalllist (T entity) {returndao.findalllist (entity); }    /*** Query Paging data *@paramPage Pagination Object *@paramEntity *@return     */     PublicPage<t> Findpage (page<t>page, T entity)        {entity.setpage (page);        Page.setlist (Dao.findlist (entity)); returnpage; }        /*** Query Paging data *@paramPage Pagination Object *@paramEntity *@return     */     PublicPage<t> Findpageover (page<t>page, T entity)        {entity.setpage (page);        Page.setlist (Dao.findlistover (entity)); returnpage; }    /*** Query for paginated data without approval *@paramPage Pagination Object *@paramEntity *@return     */     PublicPage<t> Findpagebystatus (page<t>page, T entity)        {entity.setpage (page);        Page.setlist (Dao.findlistbystatus (entity)); returnpage; }    /*** Save data (INSERT or UPDATE) *@paramEntity*/@Transactional (readOnly=false)     Public voidSave (T entity) {if(Entity.getisnewrecord ()) {Entity.preinsert (); Entity.setdelflag ("0");        Dao.insert (entity); }Else{entity.preupdate ();        Dao.update (entity); }    }        /*** Delete Data *@paramEntity*/@Transactional (readOnly=false)     Public voidDelete (T entity) {Dao.delete (entity); }        /*** Tombstone Data *@paramEntity*/@Transactional (readOnly=false)     Public voiddeletebylogic (T entity) {Dao.deletebylogic (entity); }            /*** Delete all data *@paramEntitys*/@Transactional (readOnly=false)     Public voidDeleteAll (collection<t>entitys) {         for(T entity:entitys) {dao.delete (entity); }    }        /*** Get A single piece of data *@paramPropertyName *@return     */     PublicT Finduniquebyproperty (String PropertyName, Object value) {returnDao.finduniquebyproperty (propertyname, value); }}
2.
2. back to top
3. back to top
4. back to top
5. back to top
6. back to top
Ylbtech
Source: http://ylbtech.cnblogs.com/
This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.

Java-java-com-util-common-service:crudservice.java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.