File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
src/main/java/org/javawebstack/orm/mapper Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 1010
1111public class DefaultMapper implements TypeMapper {
1212
13+ // SOURCES:
14+ // TEXT Datatypes: https://www.mysqltutorial.org/mysql-text/
15+ private static final int BYTES_OVERHEAD_VARCHAR = 4 ;
16+ private static final int BYTES_OVERHEAD_TINYTEXT = 1 ;
17+ private static final int BYTES_OVERHEAD_TEXT = 2 ;
18+ private static final int BYTES_OVERHEAD_MEDIUMTEXT = 3 ;
19+ private static final int BYTES_OVERHEAD_LONGTEXT = 4 ;
20+
21+ // The max sizes given in the manual are in bytes. There are overheads which need to be subtracted.
1322 // The following values assume utf8mb4 encoding which uses 4 bytes per character and
14- // quarters the maximum column length accordingly
15- private static final long MAX_SIZE_VARCHAR = (65535 + 1 ) / 4 ;
16- private static final long MAX_SIZE_MEDIUMTEXT = (16777215 + 1 ) / 4 ;
17- private static final long MAX_SIZE_LONGTEXT = (4294967295L + 1 ) / 4 ;
23+ // further quarters the maximum column length accordingly.
24+ private static final long MAX_SIZE_VARCHAR = (long ) Math . floor (( 65535 - BYTES_OVERHEAD_VARCHAR ) / 4 ) ;
25+ private static final long MAX_SIZE_MEDIUMTEXT = (long ) Math . floor (( 16777215 - BYTES_OVERHEAD_MEDIUMTEXT ) / 4 ) ;
26+ private static final long MAX_SIZE_LONGTEXT = (long ) Math . floor (( 4294967295L - BYTES_OVERHEAD_LONGTEXT ) / 4 ) ;
1827
1928
2029 public Object mapToSQL (Object source , Class <?> type ) {
You can’t perform that action at this time.
0 commit comments