diff --git a/Mage/src/main/java/mage/cards/repository/CardInfo.java b/Mage/src/main/java/mage/cards/repository/CardInfo.java index 7b9b62305f..d369bac186 100644 --- a/Mage/src/main/java/mage/cards/repository/CardInfo.java +++ b/Mage/src/main/java/mage/cards/repository/CardInfo.java @@ -33,6 +33,12 @@ public class CardInfo { @DatabaseField(indexName = "name_index") protected String name; + /** + * lower_name exists to speed up importing decks, specifically to provide an indexed column. + * H2 does not support expressions in indices, so we need a physical column. + */ + @DatabaseField(indexName = "lower_name_index") + protected String lower_name; @DatabaseField(indexName = "setCode_cardNumber_index") protected String cardNumber; @DatabaseField(indexName = "setCode_cardNumber_index") @@ -107,6 +113,7 @@ public class CardInfo { public CardInfo(Card card) { this.name = card.getName(); + this.lower_name = name.toLowerCase(); this.cardNumber = card.getCardNumber(); this.setCode = card.getExpansionSetCode(); this.className = card.getClass().getCanonicalName(); diff --git a/Mage/src/main/java/mage/cards/repository/CardRepository.java b/Mage/src/main/java/mage/cards/repository/CardRepository.java index 8582970702..9df069865e 100644 --- a/Mage/src/main/java/mage/cards/repository/CardRepository.java +++ b/Mage/src/main/java/mage/cards/repository/CardRepository.java @@ -58,7 +58,6 @@ public enum CardRepository { TableUtils.createTableIfNotExists(connectionSource, CardInfo.class); cardDao = DaoManager.createDao(connectionSource, CardInfo.class); - eventSource.fireRepositoryDbLoaded(); } catch (SQLException ex) { Logger.getLogger(CardRepository.class).error("Error creating card repository - ", ex); @@ -490,7 +489,7 @@ public enum CardRepository { try { String sqlName = name.toLowerCase(Locale.ENGLISH).replaceAll("'", "''"); GenericRawResults rawResults = cardDao.queryRaw( - "select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower(name) = '" + sqlName + '\'', + "select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower_name = '" + sqlName + '\'', cardDao.getRawRowMapper()); List result = new ArrayList<>(); for (CardInfo cardinfo : rawResults) {