View Javadoc

1   /**
2    * Copyright 2005-2006 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.businessobjects.environment.persistence;
16  
17  import org.figure8.join.core.persistence.HibernateObjectDao;
18  import org.figure8.join.businessobjects.environment.Machine;
19  import org.figure8.join.util.LogUtil;
20  
21  import org.apache.commons.logging.Log;
22  /**
23   * Implementation of MachineDao using Hibernate ORM system.
24   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
25   * @version $Revision: 1.1 $
26   */
27  public class HibernateMachineDao extends HibernateObjectDao implements MachineDao{
28  
29     // Static -------------------------------------------------------------------
30  
31     /** Get a commons logger */
32     private static final Log log = LogUtil.getLog(HibernateMachineDao.class);
33  
34  
35     // Implementation of MachineDao ---------------------------------------------
36  
37     /**
38      * Retrieve a Machine using its unique identifier
39      * @param id The unique identifier of machine to retrieve
40      * @return The correspnoding machine or null if no machine has this id
41      */
42     public Machine getMachine(long id){
43        return (Machine)getById(id);
44     }
45  
46     /**
47      * Retrieve a Machine using its name.
48      * @param name Name of machine to retrieve
49      * @return The machine with this name or null if no machine is found
50      */
51     public Machine getMachine(String name){
52        // Result should be a single object.
53        Machine result = (Machine)findSingleObject(findNamedQueryStringParam("join.machine_findByName", "machineName", name));
54        if (result == null)
55           log.debug("Machine with name '" + name + "' is not defined !");
56        return result;
57     }
58  
59  
60     // Implementation of ObjectDao ----------------------------------------------
61  
62     /** @return org.figure8.join.businessobjects.environment.Machine class */
63     public Class getPersistentClass(){
64        return org.figure8.join.businessobjects.environment.Machine.class;
65     }
66  }