Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-10195

Cannot create caches with different names but with same indexed types and schema name

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • None
    • 2.8
    • None
    • None

    Description

      Cannot create caches with different names but with same indexed types and schema name. In this case "javax.cache.CacheException: Index already exists: PERSON_ORGID_IDX" wil be thrown (Value has field with "origId" and annotation @QuerySqlField(index = true)).

       

      node.createCache(new CacheConfiguration<PersonKey, Person>()
       .setName("PERSON_1")
       .setQueryEntities(Arrays.asList(new QueryEntity(PersonKey.class, Person.class).setTableName("PERSON_1")))
       .setSqlSchema(QueryUtils.DFLT_SCHEMA));
      
      node.createCache(new CacheConfiguration<PersonKey, Person>()
       .setName("PERSON_2")
       .setQueryEntities(Arrays.asList(new QueryEntity(PersonKey.class, Person.class).setTableName("PERSON_2")))
       .setSqlSchema(QueryUtils.DFLT_SCHEMA));
      

       

      Here is definition of Person class:

       

      public static class PersonKey {
          @QuerySqlField
          public long id;
      
          /**
           * Constructor.
           *
           * @param id ID.
          */
          PersonKey(long id) {
              this.id = id;
          }
      
          /** {@inheritDoc} */
          Override public int hashCode() {
              return (int)id;
          }
      
          /** {@inheritDoc} */
          @Override public boolean equals(Object obj) {
              return obj != null && obj instanceof PersonKey && (F.eq(id, ((PersonKey)obj).id));
          }
      }

      Such behavior seems to be usability bug. Why I cannot create two caches with different names but with same indexed values?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              aplatonov Alexey Platonov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: