Technology : Java EE8 -wildfy (JSF2.3 + primefaces 7 + CDI +JPA )
Pom File :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.erp</groupId>
<artifactId>sampleapp</artifactId>
<version>6.11.1</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<primeface.version>7.0</primeface.version>
<jakarta.version>8.0</jakarta.version>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${jakarta.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primeface.version}</version>
</dependency>
</dependencies>
<build>
<finalName>sampleapp</finalName>
</build>
</project>
======================Service layer code ==========================
package service;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.transaction.Transactional.TxType;
import common.PersistenceService;
import dao.LoanAccountOpenDao;
import model.Loaninfo;
import model.Sanctioninfo;
@RequestScoped
@Transactional(TxType.SUPPORTS)
public class LaonAccountOpenService {
@Inject
private PersistenceService persistenceService;
@Inject
private LoanAccountOpenDao loanAccountOpenDao;
@Transactional(TxType.REQUIRED)
public void saveLoanAccount(Loaninfo loaninfo, Sanctioninfo sanctioninfo) throws Exception {
loaninfo = persistenceService.save(loaninfo);
sanctioninfo.setLoanAccountNo(loaninfo);
persistenceService.save(sanctioninfo);
}
@Transactional(TxType.REQUIRED)
public void updateLoanAccount(Loaninfo loaninfo, Sanctioninfo sanctioninfo) throws Exception {
persistenceService.update(loaninfo);
persistenceService.update(sanctioninfo);
}
public Loaninfo getLoaninfo(Integer loanAccountNo) throws Exception {
Loaninfo loaninfo = loanAccountOpenDao.getLoaninfo(loanAccountNo);
return loaninfo;
}
public Sanctioninfo getSanctioninfo(Integer sanctionNo) {
Sanctioninfo sanctiondetails = loanAccountOpenDao.getSanctiondetails(sanctionNo);
return sanctiondetails;
}
}
Comments