October 2017
Intermediate to advanced
396 pages
10h 2m
English
Let's create the following DAO implanting class:
package com.packt.patterninspring.chapter8.bankapp.dao;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.beans.factory.annotation.Autowired;
@Repository
public class AccountDaoImpl implements AccountDao {
@Autowired
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Override
public Integer totalAccountsByBranch(String branchName) {
String sql = "SELECT count(*) FROM Account WHERE branchName = "+branchName;
return this.sessionFactory.getCurrentSession().createQuery(sql, Integer.class).getSingleResult(); ...Read now
Unlock full access