001package com.avaje.ebean.config.dbplatform; 002 003/** 004 * Support for blob, mediumblob or longblob selection based on the deployment 005 * length. 006 * <p> 007 * If no deployment length is defined longblob is used. 008 * </p> 009 */ 010public class MySqlBlob extends DbType { 011 012 private static final int POWER_2_16 = 65536; 013 private static final int POWER_2_24 = 16777216; 014 015 public MySqlBlob() { 016 super("blob"); 017 } 018 019 @Override 020 public String renderType(int deployLength, int deployScale) { 021 022 if (deployLength >= POWER_2_24) { 023 return "longblob"; 024 } 025 if (deployLength >= POWER_2_16) { 026 return "mediumblob"; 027 } 028 if (deployLength < 1) { 029 // length not explicitly defined 030 return "longblob"; 031 } 032 return "blob"; 033 } 034 035}