SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

Package com.solarmetric.kodo.impl.jdbc.schema.dict

DB Dictionaries

See:
          Description

Class Summary
AbstractDictionary Abstract implementation of the DBDictionary interface for generic SQL.
DB2Dictionary Implementation of the DBDictionary interface for IBM DB2.
GenericDictionary Concrete implementation of the DBDictionary interface for generic SQL.
HSQLDictionary Implementation of the DBDictionary interface for Hypersonic SQL.
HSQLTCKDictionary Implementation of the DBDictionary interface for Hypersonic SQL, used to pass the JDO TCK.
InformixDictionary Dictionary for Informix.
MySQLDictionary Implementation of the DBDictionary interface for MySQL.
OracleDictionary Implementation of the DBDictionary interface for Oracle.
OracleDictionary.EmbeddedLob  
PointbaseDictionary Implementation of the DBDictionary interface for Pointbase Embedded.
PostgresDictionary Implementation of DBDictionary for PostgreSQL.
SQLServerDictionary Implementation of the DBDictionary interface for MS SQLServer.
SQLTypeMap Maps of java types to their SQL counterparts for a particular database.
SybaseDictionary Implementation of DBDictionary for Sybase.
 

Package com.solarmetric.kodo.impl.jdbc.schema.dict Description

DB Dictionaries

This package provides database plugins for schema manipulation on different relational database products.

Sample Code

The following represents a sample custom dictionary:

	
package com.solarmetric.kodo.impl.jdbc.schema.dict;


import java.sql.*;


/**
 *	Implementation of the DBDictionary interface for Postgresql.
 * 
 *	@author		Abe White
 */
public class PostgresDictionary
	extends GenericDictionary
{
	public String getPlatform ()
	{
		return "Postgres";
	}


	/**
	 *	Postgres does not support locking on distinct selects.
	 */
	public String toSelect (String cols, String tables, String where, 
		String order, boolean distinct, boolean update)
	{
		String sql = super.toSelect (cols, tables, where, order, distinct,
			false);

		if (update && !distinct)
			return sql + " FOR UPDATE";
		return sql;
	}


	/**
	 *	PostgreSQL seems to use '\' as a quote character as well
	 *	as '.
	 */
	protected String stringToSQL (String string)
	{
		StringBuffer buf = new StringBuffer (string.length () + 10);
		buf.append ('\'');
		for (int i = 1; i < string.length (); i++)
		{
			if (string.charAt (i) == '\\' || string.charAt (i) == '\'')
				buf.append ('\\');
			buf.append (string.charAt (i));
		}
		buf.append ('\'');
		return buf.toString ();
	}


	protected String timestampToSQL (Timestamp val)
	{
		// postgres does not support the standard
		// {ts 'datestring'} format, but it does understand
		// just the string value of the timestamp.
		return "'" + val.toString () + "'";
	}


	protected void setupSQLTypeMap (SQLTypeMap map)
	{
		map.setUnlimitedStringType ("TEXT");
		map.setDateType ("TIMESTAMP");
		map.setBooleanType ("INT2");
		map.setByteType ("INT2");
		map.setShortType ("INT2");
		map.setDoubleType ("FLOAT");
		map.setFloatType ("FLOAT");
		map.setIntType ("INT4");
		map.setLongType ("INT8");
	}
}
	


SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.