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 {library}; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
19 */
20 package ch.hortis.sonar.service;
21
22 import javax.persistence.EntityManager;
23 import javax.persistence.NoResultException;
24 import javax.persistence.Query;
25
26 import ch.hortis.sonar.model.Property;
27
28 public class PropertiesDao extends Dao {
29
30 public PropertiesDao(EntityManager manager) {
31 super(manager);
32 }
33
34 public Property getProperty(String propertyKey) {
35 Query query = manager.createNamedQuery(Property.SQL_SELECT_PROPERTY);
36 query.setParameter( "property_key", propertyKey);
37 try {
38 return (Property)query.getSingleResult();
39 } catch ( NoResultException ex ) {
40 return null;
41 }
42 }
43
44 }