11package org .zalando .typemapper .core .db ;
22
3+ import com .google .common .base .Preconditions ;
4+ import com .google .common .collect .ImmutableMap ;
5+ import org .slf4j .Logger ;
6+ import org .slf4j .LoggerFactory ;
7+
38import java .sql .Connection ;
49import java .sql .PreparedStatement ;
510import java .sql .ResultSet ;
611import java .sql .SQLException ;
7-
812import java .util .Arrays ;
913import java .util .HashMap ;
1014import java .util .LinkedList ;
1317import java .util .Map .Entry ;
1418import java .util .concurrent .ConcurrentHashMap ;
1519
16- import org .slf4j .Logger ;
17- import org .slf4j .LoggerFactory ;
18-
19- import com .google .common .base .Preconditions ;
20- import com .google .common .collect .ImmutableMap ;
21-
2220public class DbTypeRegister {
2321
2422 private static final Logger LOG = LoggerFactory .getLogger (DbTypeRegister .class );
@@ -36,18 +34,18 @@ public class DbTypeRegister {
3634
3735 private final Map <String , String > typeFQN ;
3836
39- private final Map <Integer , String > typeIdToFQN ;
37+ private final Map <Long , String > typeIdToFQN ;
4038
4139 public DbTypeRegister (final Connection connection ) throws SQLException {
4240 PreparedStatement statement = null ;
4341 ResultSet resultSet = null ;
4442 try {
4543 searchPath = getSearchPath (connection );
46- typeByName = new HashMap <String , DbType >();
44+ typeByName = new HashMap <>();
4745
4846 typeIdToFQN = new ConcurrentHashMap <>();
4947
50- final HashMap <String , List <String >> typeNameToFQN = new HashMap <String , List < String > >();
48+ final HashMap <String , List <String >> typeNameToFQN = new HashMap <>();
5149
5250 //J-
5351 statement = connection .prepareStatement (
@@ -81,15 +79,15 @@ public DbTypeRegister(final Connection connection) throws SQLException {
8179 int i = 1 ;
8280 final String typeSchema = resultSet .getString (i ++);
8381 final String typeName = resultSet .getString (i ++);
84- final int typeId = resultSet .getInt (i ++);
82+ final long typeId = resultSet .getLong (i ++);
8583 final String typeType = resultSet .getString (i ++);
8684 final String fieldName = resultSet .getString (i ++);
8785 final String fieldType = resultSet .getString (i ++);
8886 final String fieldTypeName = resultSet .getString (i ++);
89- final int fieldTypeId = resultSet .getInt (i ++);
87+ final long fieldTypeId = resultSet .getLong (i ++);
9088 final int fieldPosition = resultSet .getInt (i ++);
9189 final boolean isArray = resultSet .getBoolean (i ++);
92- final int typeElem = resultSet .getInt (i ++);
90+ final long typeElem = resultSet .getLong (i ++);
9391
9492 addField (typeSchema , typeName , typeId , fieldName , fieldPosition , fieldType , fieldTypeName , fieldTypeId ,
9593 typeType , isArray , typeNameToFQN , typeElem );
@@ -123,10 +121,10 @@ public Map<String, DbType> getTypes() {
123121 return typeByName ;
124122 }
125123
126- private void addField (final String typeSchema , final String typeName , final int typeId , final String fieldName ,
127- final int fieldPosition , final String fieldType , final String fieldTypeName , final int fieldTypeId ,
128- final String typeType , final boolean isArray , final Map <String , List <String >> typeNameToFQN ,
129- final int typeElem ) {
124+ private void addField (final String typeSchema , final String typeName , final long typeId , final String fieldName ,
125+ final int fieldPosition , final String fieldType , final String fieldTypeName , final long fieldTypeId ,
126+ final String typeType , final boolean isArray , final Map <String , List <String >> typeNameToFQN ,
127+ final long typeElem ) {
130128
131129 if (isArray ) {
132130
@@ -210,7 +208,7 @@ public static DbType getDbType(final String name, final Connection connection) t
210208 return fqName == null ? null : register .typeByName .get (fqName );
211209 }
212210
213- public static DbType getDbType (final int id , final Connection connection ) throws SQLException {
211+ public static DbType getDbType (final long id , final Connection connection ) throws SQLException {
214212 final DbTypeRegister register = getRegistry (connection );
215213 DbType type = null ;
216214
@@ -241,7 +239,7 @@ public static DbType getDbType(final int id, final Connection connection) throws
241239 PreparedStatement ps = null ;
242240 try {
243241 ps = connection .prepareStatement (sql );
244- ps .setInt (1 , id );
242+ ps .setLong (1 , id );
245243 res = ps .executeQuery ();
246244 if (res .next ()) {
247245 typeFQN = getTypeIdentifier (res .getString (1 ), res .getString (2 ));
0 commit comments