Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Sonar, open source software quality management tool.
  3. * Copyright (C) 2008-2011 SonarSource
  4. * mailto:contact AT sonarsource DOT com
  5. *
  6. * Sonar is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * Sonar is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Sonar; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
  19. */
  20. package org.sonar.jpa.dialect;
  21. import org.apache.commons.lang.StringUtils;
  22. import org.hibernate.dialect.MySQLDialect;
  23. import org.sonar.api.database.DatabaseProperties;
  24. import java.sql.Types;
  25. /**
  26. * @since 1.12
  27. */
  28. public class MySql implements Dialect {
  29. public String getId() {
  30. return "mysql";
  31. }
  32. public String getActiveRecordDialectCode() {
  33. return "mysql";
  34. }
  35. public String getActiveRecordJdbcAdapter() {
  36. return "jdbc";
  37. }
  38. public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
  39. return MySqlWithDecimalDialect.class;
  40. }
  41. public boolean matchesJdbcURL(String jdbcConnectionURL) {
  42. return StringUtils.startsWithIgnoreCase(jdbcConnectionURL, "jdbc:mysql:");
  43. }
  44. public static class MySqlWithDecimalDialect extends MySQLDialect {
  45. public MySqlWithDecimalDialect() {
  46. super();
  47. registerColumnType(Types.DOUBLE, "decimal precision");
  48. registerColumnType(Types.VARCHAR, DatabaseProperties.MAX_TEXT_SIZE, "mediumtext");
  49. registerColumnType(Types.CLOB, "mediumtext");
  50. registerColumnType(Types.BLOB, "blob");
  51. }
  52. }
  53. }