Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.owasp.appsensor.storage.jpa2.dao;
 
 
 
This is a repository/dao class for storing/retrieving org.owasp.appsensor.Event objects

Author(s):
John Melton (jtmelton@gmail.com) http://www.jtmelton.com/
public class EventRepository {
	private EntityManager em;
	public EventRepository() { }

Save org.owasp.appsensor.Event to DB

Parameters:
event org.owasp.appsensor.Event to save
	public void save(Event event) {
		Event merged = .merge(event);
		event.setId(merged.getId());
	}

Search for org.owasp.appsensor.Event by id

Parameters:
id id to search by
Returns:
single org.owasp.appsensor.Event object found by id, or null if not exists
	@Transactional(readOnly = true)
	public Event find(Integer id) {
		return .createQuery("FROM Event WHERE id = :id"Event.class)
				.setParameter("id"id)
	}

Retrive all org.owasp.appsensor.Events from the DB

	@Transactional(readOnly = true)
	public Collection<EventfindAll() {
		return .createQuery("FROM Event"Event.class).getResultList();
	}
New to GrepCode? Check out our FAQ X