[jboss-user] [EJB 3.0] - Re: SOS

zhuhuapeng@gmail.com do-not-reply at jboss.com
Tue Aug 26 09:57:13 EDT 2008


ROrganizationService:

  | package jpa.service.remote.cattle.impl;
  | 
  | import java.util.ArrayList;
  | import java.util.List;
  | 
  | import javax.ejb.EJB;
  | import javax.ejb.Local;
  | import javax.ejb.Remote;
  | import javax.ejb.Stateless;
  | import javax.ejb.TransactionAttribute;
  | import javax.ejb.TransactionAttributeType;
  | import javax.persistence.EntityManager;
  | import javax.persistence.PersistenceContext;
  | 
  | import org.apache.log4j.Logger;
  | import org.jboss.annotation.ejb.LocalBinding;
  | import org.jboss.annotation.ejb.RemoteBinding;
  | 
  | import jpa.common.CommonDBAction;
  | import jpa.entity.cattle.OrganizationEO;
  | import jpa.exp.client.DuplicateObjExp;
  | import jpa.service.local.cattle.ILOrganizationService;
  | import jpa.service.remote.cattle.IROrganizationService;
  | 
  | @Remote(value = IROrganizationService.class)
  | @RemoteBinding(jndiBinding = "ROrganizationService/remote")
  | @Local(value = ILOrganizationService.class)
  | @LocalBinding(jndiBinding = "LOrganizationService/local")
  | @Stateless
  | public class ROrganizationService implements IROrganizationService,
  | 		ILOrganizationService {
  | 
  | 	
  | 	@PersistenceContext(unitName = "cattle_ora_jpa")
  | 	private EntityManager em;
  | 	
  |     //日志记录
  | 	private static Logger logger = Logger.getLogger(ROrganizationService.class);
  | 	
  | 	public int deleteObj(int id) {
  | 		return CommonDBAction.deleteObjById(id, em, queryByID(id));
  | 	}
  | 
  | 	public List<OrganizationEO> queryAll() {
  | 	   return CommonDBAction.queryAllObjs("organizationeo_queryall", em, OrganizationEO.class);
  | 	}
  | 
  | 	//@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
  | 	public OrganizationEO queryByID(int id) {
  |        return CommonDBAction.queryByID(id, em, "organizationeo_querybyid", "id", OrganizationEO.class);
  | 	}
  | 
  | 	public OrganizationEO queryByName(String name) {
  |        return CommonDBAction.queryByName(name, em, "organizationeo_querybyname", "name",OrganizationEO.class);
  | 	}
  | 
  | 	public int storeObj(OrganizationEO eo) {
  |         List<OrganizationEO> mayMultyObjs = new ArrayList<OrganizationEO>();
  |         if(null != eo)
  |         {
  |            mayMultyObjs.add(this.queryByName(eo.getUnitName()));
  |         }
  |        return CommonDBAction.storeObj(eo, em,mayMultyObjs);
  | 	}
  | 
  | 	public OrganizationEO updateObj(OrganizationEO eo)
  | 			throws DuplicateObjExp {
  |          List<OrganizationEO> mayMultyObjs = new ArrayList<OrganizationEO>();
  |          if(null != eo)
  |          {
  |             mayMultyObjs.add(this.queryByName(eo.getUnitName()));
  |          }
  | 	     return CommonDBAction.updateObj(eo, em, mayMultyObjs, this.queryByID(eo.getId()));
  | 	}
  | }
  | 
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4172585#4172585

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4172585




More information about the jboss-user mailing list