@@ -453,7 +453,7 @@ protected T rawGet(long idToGet)
453453 }
454454 catch (Exception e )
455455 {
456- throw new EntityException (" Exception during SELECT." , e );
456+ throw new EntityException (this . name () + " Exception during SELECT." , e );
457457 }
458458 return null ;
459459 }
@@ -608,7 +608,7 @@ public void remove(long idToRemove)
608608 }
609609 catch (Exception e )
610610 {
611- throw new EntityException (" Exception during DELETE." , e );
611+ throw new EntityException (this . name () + " Exception during DELETE." , e );
612612 }
613613 }
614614
@@ -647,7 +647,7 @@ public void removeAll(Collection<Long> ids)
647647 }
648648 catch (Exception e )
649649 {
650- throw new EntityException (" Exception during DELETE (removeAll)." , e );
650+ throw new EntityException (this . name () + " Exception during DELETE (removeAll)." , e );
651651 }
652652 }
653653
@@ -684,7 +684,7 @@ protected int rawSize()
684684 }
685685 catch (Exception e )
686686 {
687- throw new EntityException (" Exception during SELECT (size)." , e );
687+ throw new EntityException (this . name () + " Exception during SELECT (size)." , e );
688688 }
689689 }
690690
@@ -726,7 +726,7 @@ protected List<T> rawList()
726726 }
727727 catch (Exception e )
728728 {
729- throw new EntityException (" Exception during SELECT (list)." , e );
729+ throw new EntityException (this . name () + " Exception during SELECT (list)." , e );
730730 }
731731 // Skip sorting if not desired.
732732 if (this .comparator != NO_COMPARATOR )
@@ -802,7 +802,7 @@ protected TLongObjectMap<T> rawMap()
802802 }
803803 catch (Exception e )
804804 {
805- throw new EntityException (" Exception during SELECT (map)." , e );
805+ throw new EntityException (this . name () + " Exception during SELECT (map)." , e );
806806 }
807807 return objects ;
808808 }
@@ -856,7 +856,7 @@ protected TLongObjectMap<T> rawMap(Collection<Long> ids)
856856 }
857857 catch (Exception e )
858858 {
859- throw new EntityException (" Exception during SELECT (map)." , e );
859+ throw new EntityException (this . name () + " Exception during SELECT (map)." , e );
860860 }
861861 return objects ;
862862 }
@@ -1050,15 +1050,15 @@ protected int insert(T object)
10501050 }
10511051 else
10521052 {
1053- throw new EntityException (" Identity not returned from INSERT." );
1053+ throw new EntityException (this . name () + " Identity not returned from INSERT." );
10541054 }
10551055 }
10561056 }
10571057 return rowsUpdated ;
10581058 }
10591059 catch (SQLException e )
10601060 {
1061- throw new EntityException (" Exception during INSERT." , e );
1061+ throw new EntityException (this . name () + " Exception during INSERT." , e );
10621062 }
10631063 }
10641064
@@ -1187,7 +1187,7 @@ protected int insertAll(Collection<T> objects)
11871187 }
11881188 if (i != objectsWithoutId .size ())
11891189 {
1190- throw new EntityException (" One or more identities not returned after INSERT." );
1190+ throw new EntityException (this . name () + " One or more identities not returned after INSERT." );
11911191 }
11921192 }
11931193 }
@@ -1207,7 +1207,7 @@ protected int insertAll(Collection<T> objects)
12071207 }
12081208 catch (SQLException e )
12091209 {
1210- throw new EntityException (" Exception during INSERT." , e );
1210+ throw new EntityException (this . name () + " Exception during INSERT." , e );
12111211 }
12121212 }
12131213
@@ -1243,7 +1243,7 @@ protected int update(T object)
12431243 }
12441244 catch (SQLException e )
12451245 {
1246- throw new EntityException (" Exception during UPDATE." , e );
1246+ throw new EntityException (this . name () + " Exception during UPDATE." , e );
12471247 }
12481248 }
12491249
@@ -1287,7 +1287,7 @@ protected int updateAll(Collection<T> objects)
12871287 }
12881288 catch (SQLException e )
12891289 {
1290- throw new EntityException (" Exception during UPDATE." , e );
1290+ throw new EntityException (this . name () + " Exception during UPDATE." , e );
12911291 }
12921292 }
12931293
@@ -1337,7 +1337,7 @@ protected long identityAggregate(String sqlAggregateFunction)
13371337 }
13381338 catch (SQLException e )
13391339 {
1340- throw new EntityException (" Exception during identity aggregate." , e );
1340+ throw new EntityException (this . name () + " Exception during identity aggregate." , e );
13411341 }
13421342 return result ;
13431343 }
@@ -1667,16 +1667,35 @@ else if (fieldType == DataFieldToMethodMap.Type.LongObject)
16671667 }
16681668 else if (fieldType == DataFieldToMethodMap .Type .Date )
16691669 {
1670- // Reduce Timestamp objects to java.util.Date objects.
1671- final Date temporary = new Date ();
1672- temporary .setTime (((Date )value ).getTime ());
1673- value = temporary ;
1670+ if (value instanceof Date )
1671+ {
1672+ // Reduce Timestamp objects to java.util.Date objects.
1673+ final Date temporary = new Date ();
1674+ temporary .setTime (((Date ) value ).getTime ());
1675+ value = temporary ;
1676+ }
1677+ else if (value instanceof LocalDateTime )
1678+ {
1679+ // Newer versions of the MySQL driver return a LocalDateTime for this field type.
1680+ LocalDateTime ldt = (LocalDateTime ) value ;
1681+ ZonedDateTime zdt = ldt .atZone (ZoneId .systemDefault ());
1682+ value = Date .from (zdt .toInstant ());
1683+ }
16741684 }
1675- else if (fieldType == DataFieldToMethodMap .Type .Calendar )
1676- {
1677- // Calendars are stored as dates.
1678- value = DateHelper .getCalendarInstance (
1679- ((java .util .Date )value ).getTime ());
1685+ else if (fieldType == DataFieldToMethodMap .Type .Calendar ) {
1686+ if (value instanceof Date )
1687+ {
1688+ // Calendars are stored as dates.
1689+ value = DateHelper .getCalendarInstance (
1690+ ((java .util .Date ) value ).getTime ());
1691+ }
1692+ else if (value instanceof LocalDateTime )
1693+ {
1694+ // Newer versions of the MySQL driver return a LocalDateTime for this field type.
1695+ LocalDateTime ldt = (LocalDateTime )value ;
1696+ ZonedDateTime zdt = ldt .atZone (ZoneId .systemDefault ());
1697+ value = GregorianCalendar .from (zdt );
1698+ }
16801699 }
16811700 else if (fieldType == DataFieldToMethodMap .Type .LocalDate )
16821701 {
@@ -1878,7 +1897,7 @@ private List<DatabaseColumnMetaData> getMetadataFromResultSet(ResultSet resultSe
18781897 // If neither the table or result set has worked, let's fail.
18791898 if (CollectionHelper .isEmpty (metaData ))
18801899 {
1881- throw new EntityException (" Could not read meta data for table \" "
1900+ throw new EntityException (this . name () + " Could not read meta data for table \" "
18821901 + this .table + "\" ." );
18831902 }
18841903
@@ -2079,7 +2098,7 @@ public T make(ResultSet resultSet)
20792098 }
20802099 catch (SQLException e )
20812100 {
2082- throw new EntityException (" Exception while fetching identity during object initialization." , e );
2101+ throw new EntityException (this . name () + " Exception while fetching identity during object initialization." , e );
20832102 }
20842103
20852104 final DataFieldToMethodMap [] mappings = getSetMethodMappingCache (resultSet );
@@ -2099,7 +2118,7 @@ public T make(ResultSet resultSet)
20992118 }
21002119 catch (Exception e )
21012120 {
2102- throw new EntityException ("Exception during object initialization (" + map .getMethod ().getName () + ")." , e );
2121+ throw new EntityException ("Exception during " + this . name () + " object initialization (" + map .getMethod ().getName () + ")." , e );
21032122 }
21042123 }
21052124
@@ -2194,8 +2213,7 @@ public static Collection<DatabaseColumnMetaData> getColumnMetaDataForTable(Conne
21942213
21952214 // Sometimes a table name is escaped with backquotes, but those
21962215 // break this call to getColumns.
2197-
2198- ResultSet resultSet = metaData .getColumns (null , null , StringHelper .replaceSubstrings (tableName , "`" , "" ), "%" );
2216+ ResultSet resultSet = metaData .getColumns (connection .getCatalog (), null , StringHelper .replaceSubstrings (tableName , "`" , "" ), "%" );
21992217
22002218 while (resultSet .next ())
22012219 {
0 commit comments