001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: HibernateQuery.java,v $
031: * Revision 1.4 2005/10/11 18:51:38 colinmacleod
032: * Fixed some checkstyle and javadoc issues.
033: *
034: * Revision 1.3 2005/10/02 14:08:56 colinmacleod
035: * Added/improved log4j logging.
036: *
037: * Revision 1.2 2005/04/09 17:19:37 colinmacleod
038: * Changed copyright text to GPL v2 explicitly.
039: *
040: * Revision 1.1 2005/03/10 19:23:04 colinmacleod
041: * Moved to ivata groupware.
042: *
043: * Revision 1.1 2004/07/13 19:42:44 colinmacleod
044: * Moved project to POJOs from EJBs.
045: * Applied PicoContainer to services layer (replacing session EJBs).
046: * Applied Hibernate to persistence layer (replacing entity EJBs).
047: * -----------------------------------------------------------------------------
048: */
049: package com.ivata.groupware.container.persistence.hibernate;
050:
051: import org.apache.log4j.Logger;
052:
053: import java.util.Map;
054:
055: /**
056: * Implementation of a query to be executed by
057: * {@link com.ivata.groupware.container.persistence.hibernate.HibernateManager}.
058: * This combines query strings with the argument names and values.
059: *
060: * @author Colin MacLeod
061: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
062: * @since ivata groupware 0.10 (Mar 27, 2004)
063: * @version $Revision: 1.4 $
064: */
065: public class HibernateQuery {
066: /**
067: * Logger for this class.
068: */
069: private static final Logger logger = Logger
070: .getLogger(HibernateQuery.class);
071:
072: /**
073: * <copyDoc>Refer to {@link #getQueryString}.</copyDoc>
074: */
075: private String queryString;
076: /**
077: * <copyDoc>Refer to {@link #getArguments}.</copyDoc>
078: */
079: private Map arguments;
080:
081: /**
082: * Constructor.
083: *
084: * @param queryStringParam
085: * <copyDoc>Refer to {@link #getQueryString}.</copyDoc>
086: * @param argumentsParam
087: * <copyDoc>Refer to {@link #getArguments}.</copyDoc>
088: */
089: public HibernateQuery(final String queryStringParam,
090: final Map argumentsParam) {
091: super ();
092: this .queryString = queryStringParam;
093: this .arguments = argumentsParam;
094: }
095:
096: /**
097: * Get the Hibernate query string to be executed.
098: *
099: * @return The Hibernate query string to be executed.
100: */
101: public String getQueryString() {
102: if (logger.isDebugEnabled()) {
103: logger.debug("getQueryString() - start");
104: }
105:
106: if (logger.isDebugEnabled()) {
107: logger.debug("getQueryString() - end - return value = "
108: + queryString);
109: }
110: return queryString;
111: }
112:
113: /**
114: * Get a mapping of named query arguments and their values.
115: *
116: * @return Mapping of named query arguments and their values.
117: */
118: public Map getArguments() {
119: if (logger.isDebugEnabled()) {
120: logger.debug("getArguments() - start");
121: }
122:
123: if (logger.isDebugEnabled()) {
124: logger.debug("getArguments() - end - return value = "
125: + arguments);
126: }
127: return arguments;
128: }
129: }
|