Skip to content

Instantly share code, notes, and snippets.

@evrentan
Created March 28, 2021 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evrentan/7b9d5c60e4851838ed853be6e7a6f42a to your computer and use it in GitHub Desktop.
Save evrentan/7b9d5c60e4851838ed853be6e7a6f42a to your computer and use it in GitHub Desktop.
Service Class Implementing Interface Class
package com.tan.example.service;
import com.tan.example.entity.EnterpriseEntity;
import org.bson.types.ObjectId;
import javax.enterprise.context.ApplicationScoped;
import javax.transaction.Transactional;
import javax.validation.Valid;
import java.util.List;
@ApplicationScoped
@Transactional(Transactional.TxType.REQUIRED)
public class EnterpriseService implements EnterpriseInterface {
public List<EnterpriseEntity> findAllEnterprises() {
return EnterpriseEntity.listAll();
}
public EnterpriseEntity findEnterpriseById(String id) {
final ObjectId enterpriseId = new ObjectId(id);
return EnterpriseEntity.findById(enterpriseId);
}
public EnterpriseEntity createEnterprise(@Valid EnterpriseEntity enterpriseEntity) {
EnterpriseEntity.persist(enterpriseEntity);
return enterpriseEntity;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment