package com.javaskool;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;

public class PassengerDAO {
	
   @SessionTarget
   Session session;

   @TransactionTarget
   Transaction transaction;
   

   @SuppressWarnings("unchecked")
   public List<Passenger> getPassengers()
   {
      List<Passenger> passengers = new ArrayList<Passenger>();
      try
      {
    	  passengers = session.createQuery("from Passenger").list();
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
      return passengers;
   }

   public void addPassenger(Passenger passenger) throws HibernateException
   {
      session.save(passenger);
   }
}
