1 /* 2 * Sonar, entreprise quality control tool. 3 * Copyright (C) 2007-2008 Hortis-GRC SA 4 * mailto:be_agile HAT hortis DOT ch 5 * 6 * Sonar is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 3 of the License, or (at your option) any later version. 10 * 11 * Sonar is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with Sonar; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 19 */ 20 package org.sonar.commons.database; 21 22 import javax.persistence.EntityManager; 23 import javax.persistence.Query; 24 25 public interface DatabaseManager { 26 void start(); 27 28 void stop(); 29 30 EntityManager getEntityManager(); 31 32 Object save(Object model); 33 34 Object merge(Object model); 35 36 void remove(Object model); 37 38 <T> T reattach(Class<T> entityClass, Object primaryKey); 39 40 void commit(); 41 42 void rollback(); 43 44 Query createQuery(String hql); 45 46 Query createNamedQuery(String hql); 47 48 Object getSingleResult(Query query, Object defaultValue); 49 50 51 }