package com.mysema.query;

import static com.mysema.query.Target.CUBRID;
import static com.mysema.query.Target.POSTGRES;
import static com.mysema.query.Target.TERADATA;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.junit.Test;

import com.mysema.testutil.ExcludeIn;

public class TypesBase extends AbstractBaseTest {

    @Test
    @ExcludeIn({CUBRID, POSTGRES, TERADATA})
    public void DumpTypes() throws SQLException {
        Connection conn = Connections.getConnection();
        DatabaseMetaData md = conn.getMetaData();

        // types
        ResultSet rs = md.getUDTs(null, null, null, null);
        try {
            while (rs.next()) {
                // cat, schema, name, classname, datatype, remarks, base_type
                String cat = rs.getString(1);
                String schema = rs.getString(2);
                String name = rs.getString(3);
                String classname = rs.getString(4);
                String datatype = rs.getString(5);
                String remarks = rs.getString(6);
                String base_type = rs.getString(7);
                System.out.println(name + " " + classname + " " + datatype + " " +
                                   remarks + " " + base_type);

                // attributes
                ResultSet rs2 = md.getAttributes(cat, schema, name, null);
                try {
                    while (rs2.next()) {
                        // cat, schema, name, attr_name, data_type, attr_type_name, attr_size
                        // decimal_digits, num_prec_radix, nullable, remarks, attr_def, sql_data_type, ordinal_position
                        // ...
                        String _cat = rs2.getString(1);
                        String _schema = rs2.getString(2);
                        String _name = rs2.getString(3);
                        String _attr_name = rs2.getString(4);
                        String _data_type = rs2.getString(5);
                        String _attr_type_name = rs2.getString(6);
                        String _attr_size = rs2.getString(7);

                        System.out.println(" " + _attr_name + " " + _data_type + " " + _attr_type_name + " " + _attr_size);
                    }
                } finally {
                    rs2.close();
                }
            }
        } finally {
            rs.close();
        }
    }

}

@@ -62,112 +62,69 @@
 get.
-CUBRID
+*
 ;%0A
+%0A
 import 
-static com.mysema.query.Target.POSTGRES;%0Aimport static com.mysema.query.Target.TERADATA;%0A
+java.math.BigDecimal;%0Aimport java.math.BigInteger;
 %0Aimp
@@ -238,16 +238,38 @@
 ception;
+%0Aimport java.util.Map;
 %0A%0Aimport
@@ -301,85 +301,1502 @@
 com.
-mysema.testutil.ExcludeIn;%0A%0Apublic class TypesBase extends AbstractBaseTest %7B
+google.common.collect.Maps;%0Aimport com.mysema.query.ddl.CreateTableClause;%0Aimport com.mysema.query.ddl.DropTableClause;%0Aimport com.mysema.testutil.ExcludeIn;%0A%0Apublic class TypesBase extends AbstractBaseTest %7B%0A%0A    @Test%0A    public void CreateTables() %7B%0A        Map%3CClass%3C?%3E, Object%3E instances = Maps.newHashMap();%0A        instances.put(BigInteger.class, BigInteger.valueOf(1));%0A        instances.put(Long.class, Long.valueOf(1));%0A        instances.put(Integer.class, Integer.valueOf(1));%0A        instances.put(Short.class, Short.valueOf((short)1));%0A        instances.put(Byte.class, Byte.valueOf((byte)1));%0A        instances.put(BigDecimal.class, BigDecimal.valueOf(1.0));%0A        instances.put(Double.class, Double.valueOf(1.0));%0A        instances.put(Float.class, Float.valueOf((float)1.0));%0A        instances.put(Boolean.class, Boolean.TRUE);%0A        instances.put(Character.class, Character.valueOf('a'));%0A        instances.put(String.class, %22ABC%22);%0A%0A        for (Map.Entry%3CClass%3C?%3E, Object%3E entry : instances.entrySet()) %7B%0A            String tableName = %22test_%22 + entry.getKey().getSimpleName();%0A            CreateTableClause c = new CreateTableClause(connection, configuration, tableName)%0A                    .column(%22col%22, entry.getKey());%0A            if (entry.getKey().equals(String.class)) %7B%0A                c.size(256);%0A            %7D%0A            c.execute();%0A            // TODO insert%0A            new DropTableClause(connection, configuration, tableName).execute();%0A        %7D%0A%0A    %7D
 %0A%0A  

Add more type related tests