[ https://issues.apache.org/jira/browse/IGNITE-10195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexey Platonov updated IGNITE-10195: ------------------------------------- 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)). {code:java} 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)); {code} Here is definition of Person class: {code:java} 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)); } }{code} Such behavior seems to be usability bug. Why I cannot create two caches with different names but with same indexed values? was: Cannot create caches with different names but with same indexed types and schema name. {code:java} 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)); {code} If I set table name manually by setQueryEntities(...) then "javax.cache.CacheException: Index already exists: PERSON_ORGID_IDX" wil be thrown (Value has field with "origId" and annotation @QuerySqlField(index = true)). Here is definition of Person class: {code:java} 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)); } }{code} Such behavior seems to be usability bug. Why I cannot create two caches with different names but with same indexed values? > Cannot create caches with different names but with same indexed types and > schema name > ------------------------------------------------------------------------------------- > > Key: IGNITE-10195 > URL: https://issues.apache.org/jira/browse/IGNITE-10195 > Project: Ignite > Issue Type: Improvement > Reporter: Alexey Platonov > Priority: Major > > 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)). > > {code:java} > 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)); > {code} > > Here is definition of Person class: > > {code:java} > 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)); > } > }{code} > Such behavior seems to be usability bug. Why I cannot create two caches with > different names but with same indexed values? -- This message was sent by Atlassian JIRA (v7.6.3#76005)