01: /**
02: * Copyright (C) 2006 NetMind Consulting Bt.
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 3 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package hu.netmind.persistence;
18:
19: import java.sql.Types;
20: import java.util.List;
21:
22: /**
23: * Postgres database implementation.
24: * @author Brautigam Robert
25: * @version CVS Revision: $Revision$
26: */
27: public class PostgresDatabaseImpl extends GenericDatabase {
28: /**
29: * Get the limit component of statement, if it can be expressed in
30: * the current database with simple statement part.
31: * @param limits The limits to apply.
32: */
33: protected String getLimitStatement(String statement, Limits limits,
34: List types) {
35: StringBuffer result = new StringBuffer(statement);
36: if (limits.getLimit() > 0)
37: result.append(" limit " + limits.getLimit());
38: if (limits.getOffset() > 0)
39: result.append(" offset " + limits.getOffset());
40: return result.toString();
41: }
42:
43: /**
44: * Get the class for an sql type. Override for blob type.
45: */
46: protected String getSQLTypeName(int sqltype) {
47: switch (sqltype) {
48: case Types.BINARY:
49: case Types.BLOB:
50: return "bytea";
51: default:
52: return super.getSQLTypeName(sqltype);
53: }
54: }
55:
56: }
|