Teaching Management System-Session Bean

Source: Internet
Author: User

Collegeservice is a remote interface. Most remote interfaces have similar operations to add, delete, modify, and query. Therefore, a parent interface iservice is defined. To reduce unnecessary type conversions, use generics when defining iservice. When collegeservice is derived from iserive, it is bound to define the college.

Collegeservicebean is a stateless Session Bean identified by @ stateless. It implements the collegeservice interface and derives from abstractserviebean. Abstractbean provides the default implementation for adding, deleting, modifying, and querying operations.

Iservice_college and abstractservicebean_college in the figure indicate the binding to the generic type. They do not have Code and are embodied when the child type is derived.

package org.bnuitse.tms.service.security;
import java.util.List;
import org.bnuitse.tms.model.security.College;
import org.bnuitse.tms.service.IService;
public interface CollegeService extends IService<College>{
 String jndiName = "tms/security/CollegeService";
 College find(String name);
}
 
package org.bnuitse.tms.service.security.impl;
import java.util.List;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import org.bnuitse.tms.model.security.College;
import org.bnuitse.tms.service.AbstractServiceBean;
import org.bnuitse.tms.service.security.CollegeService;
import org.jboss.annotation.ejb.RemoteBinding;
@Stateless
@Remote(CollegeService.class)
@RemoteBinding(jndiBinding = CollegeService.jndiName)
public class CollegeServiceBean extends AbstractServiceBean<College> implements CollegeService {
 public College find(String name) {
  return (College) em.createQuery("from College o where o.name = :name").setParameter("name", name).getSingleResult();
 }
}

 

 

Related Article

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.