// Path: chapter04/src/main/java/com/packt/pfblueprints/model/Representative.java
// public class Representative implements Serializable{
// 
// 	private static final long serialVersionUID = 1L;
// 	private int id;
// 	private String repnumber;
// 	private String repname;
// 	private String advisornumber;
// 	private String dor;
// 	private String branch;
// 	private String status;
// 	
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	
// 	public String getRepnumber() {
// 		return repnumber;
// 	}
// 	public void setRepnumber(String repnumber) {
// 		this.repnumber = repnumber;
// 	}
// 	public String getRepname() {
// 		return repname;
// 	}
// 	public void setRepname(String repname) {
// 		this.repname = repname;
// 	}
// 	public String getAdvisornumber() {
// 		return advisornumber;
// 	}
// 	public void setAdvisornumber(String advisornumber) {
// 		this.advisornumber = advisornumber;
// 	}
// 	public String getDor() {
// 		return dor;
// 	}
// 	public void setDor(String dor) {
// 		this.dor = dor;
// 	}
// 	public String getBranch() {
// 		return branch;
// 	}
// 	public void setBranch(String branch) {
// 		this.branch = branch;
// 	}
// 	public String getStatus() {
// 		return status;
// 	}
// 	public void setStatus(String status) {
// 		this.status = status;
// 	}
// 
// }


import java.util.List;
import java.util.Map;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import com.packt.pfblueprints.model.Representative;

package com.packt.pfblueprints.dao;





public class AdvisorDAO {

	private  SessionFactory sessionFactory;
	private  String advisorNumber;

	private  SessionFactory configureSessionFactory()
			throws HibernateException {
		Configuration configuration = new Configuration();
		configuration.configure();
		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder()
				.applySettings(configuration.getProperties());
		SessionFactory sessionfactory = configuration
				.buildSessionFactory(builder.build());
		return sessionfactory;
	}
    
	public AdvisorDAO() {
		super();
		
		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
		Map<String, Object> sessionMap = externalContext.getSessionMap();
		advisorNumber=(String) sessionMap.get("advisornumber");
	}


// Path: chapter04/src/main/java/com/packt/pfblueprints/model/Representative.java
// public class Representative implements Serializable{
// 
// 	private static final long serialVersionUID = 1L;
// 	private int id;
// 	private String repnumber;
// 	private String repname;
// 	private String advisornumber;
// 	private String dor;
// 	private String branch;
// 	private String status;
// 	
// 	public int getId() {
// 		return id;
// 	}
// 	public void setId(int id) {
// 		this.id = id;
// 	}
// 	
// 	public String getRepnumber() {
// 		return repnumber;
// 	}
// 	public void setRepnumber(String repnumber) {
// 		this.repnumber = repnumber;
// 	}
// 	public String getRepname() {
// 		return repname;
// 	}
// 	public void setRepname(String repname) {
// 		this.repname = repname;
// 	}
// 	public String getAdvisornumber() {
// 		return advisornumber;
// 	}
// 	public void setAdvisornumber(String advisornumber) {
// 		this.advisornumber = advisornumber;
// 	}
// 	public String getDor() {
// 		return dor;
// 	}
// 	public void setDor(String dor) {
// 		this.dor = dor;
// 	}
// 	public String getBranch() {
// 		return branch;
// 	}
// 	public void setBranch(String branch) {
// 		this.branch = branch;
// 	}
// 	public String getStatus() {
// 		return status;
// 	}
// 	public void setStatus(String status) {
// 		this.status = status;
// 	}
// 
// }


// Path: chapter04/src/main/java/com/packt/pfblueprints/dao/AdvisorDAO.java
import java.util.List;
import java.util.Map;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import com.packt.pfblueprints.model.Representative;

package com.packt.pfblueprints.dao;





public class AdvisorDAO {

	private  SessionFactory sessionFactory;
	private  String advisorNumber;

	private  SessionFactory configureSessionFactory()
			throws HibernateException {
		Configuration configuration = new Configuration();
		configuration.configure();
		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder()
				.applySettings(configuration.getProperties());
		SessionFactory sessionfactory = configuration
				.buildSessionFactory(builder.build());
		return sessionfactory;
	}
    
	public AdvisorDAO() {
		super();
		
		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
		Map<String, Object> sessionMap = externalContext.getSessionMap();
		advisorNumber=(String) sessionMap.get("advisornumber");
	}


	public List<Representative> getAllRepresentatives() {
