Skip to content

Commit

Permalink
Merge pull request #115 from k-r-g/mysql-jdbc-driver-8.0.23-compatibi…
Browse files Browse the repository at this point in the history
…lity

Mysql jdbc driver 8.0.23 compatibility
  • Loading branch information
msmith-techempower authored Jun 6, 2022
2 parents af356c5 + 45a6061 commit 97e94fb
Showing 1 changed file with 46 additions and 28 deletions.
74 changes: 46 additions & 28 deletions gemini/src/main/java/com/techempower/data/EntityGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ protected T rawGet(long idToGet)
}
catch (Exception e)
{
throw new EntityException("Exception during SELECT.", e);
throw new EntityException(this.name() + " Exception during SELECT.", e);
}
return null;
}
Expand Down Expand Up @@ -608,7 +608,7 @@ public void remove(long idToRemove)
}
catch (Exception e)
{
throw new EntityException("Exception during DELETE.", e);
throw new EntityException(this.name() + " Exception during DELETE.", e);
}
}

Expand Down Expand Up @@ -647,7 +647,7 @@ public void removeAll(Collection<Long> ids)
}
catch (Exception e)
{
throw new EntityException("Exception during DELETE (removeAll).", e);
throw new EntityException(this.name() + " Exception during DELETE (removeAll).", e);
}
}

Expand Down Expand Up @@ -684,7 +684,7 @@ protected int rawSize()
}
catch (Exception e)
{
throw new EntityException("Exception during SELECT (size).", e);
throw new EntityException(this.name() + " Exception during SELECT (size).", e);
}
}

Expand Down Expand Up @@ -726,7 +726,7 @@ protected List<T> rawList()
}
catch (Exception e)
{
throw new EntityException("Exception during SELECT (list).", e);
throw new EntityException(this.name() + " Exception during SELECT (list).", e);
}
// Skip sorting if not desired.
if (this.comparator != NO_COMPARATOR)
Expand Down Expand Up @@ -802,7 +802,7 @@ protected TLongObjectMap<T> rawMap()
}
catch (Exception e)
{
throw new EntityException("Exception during SELECT (map).", e);
throw new EntityException(this.name() + " Exception during SELECT (map).", e);
}
return objects;
}
Expand Down Expand Up @@ -856,7 +856,7 @@ protected TLongObjectMap<T> rawMap(Collection<Long> ids)
}
catch (Exception e)
{
throw new EntityException("Exception during SELECT (map).", e);
throw new EntityException(this.name() + " Exception during SELECT (map).", e);
}
return objects;
}
Expand Down Expand Up @@ -1050,15 +1050,15 @@ protected int insert(T object)
}
else
{
throw new EntityException("Identity not returned from INSERT.");
throw new EntityException(this.name() + " Identity not returned from INSERT.");
}
}
}
return rowsUpdated;
}
catch (SQLException e)
{
throw new EntityException("Exception during INSERT.", e);
throw new EntityException(this.name() + " Exception during INSERT.", e);
}
}

Expand Down Expand Up @@ -1187,7 +1187,7 @@ protected int insertAll(Collection<T> objects)
}
if (i != objectsWithoutId.size())
{
throw new EntityException("One or more identities not returned after INSERT.");
throw new EntityException(this.name() + " One or more identities not returned after INSERT.");
}
}
}
Expand All @@ -1207,7 +1207,7 @@ protected int insertAll(Collection<T> objects)
}
catch (SQLException e)
{
throw new EntityException("Exception during INSERT.", e);
throw new EntityException(this.name() + " Exception during INSERT.", e);
}
}

Expand Down Expand Up @@ -1243,7 +1243,7 @@ protected int update(T object)
}
catch (SQLException e)
{
throw new EntityException("Exception during UPDATE.", e);
throw new EntityException(this.name() + " Exception during UPDATE.", e);
}
}

Expand Down Expand Up @@ -1287,7 +1287,7 @@ protected int updateAll(Collection<T> objects)
}
catch (SQLException e)
{
throw new EntityException("Exception during UPDATE.", e);
throw new EntityException(this.name() + " Exception during UPDATE.", e);
}
}

Expand Down Expand Up @@ -1337,7 +1337,7 @@ protected long identityAggregate(String sqlAggregateFunction)
}
catch (SQLException e)
{
throw new EntityException("Exception during identity aggregate.", e);
throw new EntityException(this.name() + " Exception during identity aggregate.", e);
}
return result;
}
Expand Down Expand Up @@ -1667,16 +1667,35 @@ else if (fieldType == DataFieldToMethodMap.Type.LongObject)
}
else if (fieldType == DataFieldToMethodMap.Type.Date)
{
// Reduce Timestamp objects to java.util.Date objects.
final Date temporary = new Date();
temporary.setTime(((Date)value).getTime());
value = temporary;
if (value instanceof Date)
{
// Reduce Timestamp objects to java.util.Date objects.
final Date temporary = new Date();
temporary.setTime(((Date) value).getTime());
value = temporary;
}
else if (value instanceof LocalDateTime)
{
// Newer versions of the MySQL driver return a LocalDateTime for this field type.
LocalDateTime ldt = (LocalDateTime) value;
ZonedDateTime zdt = ldt.atZone(ZoneId.systemDefault());
value = Date.from(zdt.toInstant());
}
}
else if (fieldType == DataFieldToMethodMap.Type.Calendar)
{
// Calendars are stored as dates.
value = DateHelper.getCalendarInstance(
((java.util.Date)value).getTime());
else if (fieldType == DataFieldToMethodMap.Type.Calendar) {
if (value instanceof Date)
{
// Calendars are stored as dates.
value = DateHelper.getCalendarInstance(
((java.util.Date) value).getTime());
}
else if (value instanceof LocalDateTime)
{
// Newer versions of the MySQL driver return a LocalDateTime for this field type.
LocalDateTime ldt = (LocalDateTime)value;
ZonedDateTime zdt = ldt.atZone(ZoneId.systemDefault());
value = GregorianCalendar.from(zdt);
}
}
else if (fieldType == DataFieldToMethodMap.Type.LocalDate)
{
Expand Down Expand Up @@ -1878,7 +1897,7 @@ private List<DatabaseColumnMetaData> getMetadataFromResultSet(ResultSet resultSe
// If neither the table or result set has worked, let's fail.
if (CollectionHelper.isEmpty(metaData))
{
throw new EntityException("Could not read meta data for table \""
throw new EntityException(this.name() + " Could not read meta data for table \""
+ this.table + "\".");
}

Expand Down Expand Up @@ -2079,7 +2098,7 @@ public T make(ResultSet resultSet)
}
catch (SQLException e)
{
throw new EntityException("Exception while fetching identity during object initialization.", e);
throw new EntityException(this.name() + " Exception while fetching identity during object initialization.", e);
}

final DataFieldToMethodMap[] mappings = getSetMethodMappingCache(resultSet);
Expand All @@ -2099,7 +2118,7 @@ public T make(ResultSet resultSet)
}
catch (Exception e)
{
throw new EntityException("Exception during object initialization (" + map.getMethod().getName() + ").", e);
throw new EntityException("Exception during " + this.name() + " object initialization (" + map.getMethod().getName() + ").", e);
}
}

Expand Down Expand Up @@ -2194,8 +2213,7 @@ public static Collection<DatabaseColumnMetaData> getColumnMetaDataForTable(Conne

// Sometimes a table name is escaped with backquotes, but those
// break this call to getColumns.

ResultSet resultSet = metaData.getColumns(null, null, StringHelper.replaceSubstrings(tableName, "`", ""), "%");
ResultSet resultSet = metaData.getColumns(connection.getCatalog(), null, StringHelper.replaceSubstrings(tableName, "`", ""), "%");

while (resultSet.next())
{
Expand Down

0 comments on commit 97e94fb

Please sign in to comment.