View Javadoc

1   package org.minetti.astrodevice.server.hibernate.dao;
2   
3   import javax.persistence.EntityManager;
4   import org.minetti.astrodevice.server.core.dao.DaoSession;
5   
6   /**
7    * Session used for the DAO with Hibernate framework.
8    * @author Jean-Philippe MINETTI
9    */
10  public final class DaoSessionImpl
11  		implements DaoSession {
12  
13  	/**
14  	 * Entity manager.
15  	 */
16  	private final EntityManager entityManager;
17  
18  	/**
19  	 * Hidden constructor.
20  	 * @param entityManager Entity manager.
21  	 * @see DaoModuleImpl#newDaoSession()
22  	 */
23  	protected DaoSessionImpl (final EntityManager entityManager) {
24  		super();
25  		this.entityManager = entityManager;
26  	}
27  
28  	/**
29  	 * Returns the entity manager.
30  	 * @return Entity manager.
31  	 */
32  	protected EntityManager getEntityManager () {
33  		return this.entityManager;
34  	}
35  
36  	/*
37  	 * (non-Javadoc)
38  	 * @see org.minetti.astrodevice.server.core.dao.DaoSession#close()
39  	 */
40  	public void close () {
41  		this.entityManager.close();
42  	}
43  
44  	/*
45  	 * (non-Javadoc)
46  	 * @see java.lang.Object#toString()
47  	 */
48  	@Override
49  	public String toString () {
50  		return "DaoSessionImpl[entityManager=" + this.entityManager + "]";
51  	}
52  
53  }