Code example for SessionFactory

Methods: getCurrentSession

0
	 * @return List<Note> object of all Notes from the database 
	 */ 
	@SuppressWarnings("unchecked") 
	public List<Note> getNotes() {
		log.info("Getting all notes from the database");
		return sessionFactory.getCurrentSession().createQuery("from Note").list();
	} 
	 
	/** 
	 * @see org.openmrs.api.db.NoteDAO#getNote(Integer) 
	 */ 
	public Note getNote(Integer id) {
		log.info("Get note " + id);
		return (Note) sessionFactory.getCurrentSession().get(Note.class, id);
	} 
	 
	public void createNote(Note note) {
		log.debug("Creating new note");
		sessionFactory.getCurrentSession().save(note);
	}