[ 
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. For example, such code will throw exception 
"javax.cache.CacheException: Table already exists: PERSON".

 
{code:java}
node.createCache(new CacheConfiguration<PersonKey, Person>()
 .setName("PERSON_1")
 .setIndexedTypes(Key.class, Person.class)
 .setSqlSchema(QueryUtils.DFLT_SCHEMA));

node.createCache(new CacheConfiguration<PersonKey, Person>()
 .setName("PERSON_2")
 .setIndexedTypes(Key.class, Person.class)
 .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{color:#629755}} */
@Override public int hashCode() {
return (int)id; }

/** {@inheritDoc{color:#629755}} */
@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. For example, such code will throw exception 
"javax.cache.CacheException: Table already exists: PERSON".

 
{code:java}
node.createCache(new CacheConfiguration<PersonKey, Person>()
 .setName("PERSON_1")
 .setIndexedTypes(Key.class, Person.class)
 .setSqlSchema(QueryUtils.DFLT_SCHEMA));

node.createCache(new CacheConfiguration<PersonKey, Person>()
 .setName("PERSON_2")
 .setIndexedTypes(Key.class, Person.class)
 .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 
{color:#bbb529}@QuerySqlField{color}({color:#d0d0ff}index {color}= 
{color:#cc7832}true{color})). Here is definition of Person class:

 \{code} 

{color:#cc7832}public static class {color}PersonKey {
 {color:#bbb529}@QuerySqlField{color} {color:#cc7832}public long 
{color}{color:#9876aa}id{color}{color:#cc7832};{color} 
{color:#629755}/**{color}{color:#629755} * Constructor.{color}{color:#629755} 
*{color}{color:#629755} * {color}{color:#629755}@param {color}{color:#8a653b}id 
{color}{color:#629755}ID.{color}{color:#629755} */{color} 
{color:#ffc66d}PersonKey{color}({color:#cc7832}long {color}id) {
 {color:#cc7832}this{color}.{color:#9876aa}id {color}= 
id{color:#cc7832};{color} }

{color:#629755}/** {{color}{color:#629755}@inheritDoc{color}{color:#629755}} */
 @Override {color:#cc7832}public int {color}{color:#ffc66d}hashCode{color}() {
 {color:#cc7832}return 
{color}({color:#cc7832}int{color}){color:#9876aa}id{color}{color:#cc7832};{color}
 }

{color:#629755}/** {{color}{color:#629755}@inheritDoc{color}{color:#629755}} */
 @Override {color:#cc7832}public boolean 
{color}{color:#ffc66d}equals{color}(Object obj) {
 {color:#cc7832}return {color}obj != {color:#cc7832}null {color}&& obj 
{color:#cc7832}instanceof {color}PersonKey && 
(F.eq({color:#9876aa}id{color}{color:#cc7832}, 
{color}((PersonKey)obj).{color:#9876aa}id{color})){color:#cc7832};{color} }
 }

 \{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. For example, such code will throw exception 
> "javax.cache.CacheException: Table already exists: PERSON".
>  
> {code:java}
> node.createCache(new CacheConfiguration<PersonKey, Person>()
>  .setName("PERSON_1")
>  .setIndexedTypes(Key.class, Person.class)
>  .setSqlSchema(QueryUtils.DFLT_SCHEMA));
> node.createCache(new CacheConfiguration<PersonKey, Person>()
>  .setName("PERSON_2")
>  .setIndexedTypes(Key.class, Person.class)
>  .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{color:#629755}} */
> @Override public int hashCode() {
> return (int)id; }
> /** {@inheritDoc{color:#629755}} */
> @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)

Reply via email to