ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eduard Shangareev (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (IGNITE-10195) Cannot create caches with different names but with same indexed types and schema name
Date Thu, 08 Nov 2018 15:53:00 GMT

     [ https://issues.apache.org/jira/browse/IGNITE-10195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Eduard Shangareev 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}
{color:#9876aa}node{color}.createCache({color:#cc7832}new {color}CacheConfiguration<PersonKey{color:#cc7832},
{color}Person>()
 .setName({color:#9876aa}"PERSON_1"{color})
 .setIndexedTypes(Key.{color:#cc7832}class,{color} Person.{color:#cc7832}class{color})
 .setSqlSchema(QueryUtils.{color:#9876aa}DFLT_SCHEMA{color})){color:#cc7832};{color}{color:#9876aa}node{color}.createCache({color:#cc7832}new
{color}CacheConfiguration<PersonKey{color:#cc7832}, {color}Person>()
 .setName({color:#9876aa}"PERSON_2"{color})
 .setIndexedTypes({color:#cc7832}Key.class, Person.class{color})
 .setSqlSchema(QueryUtils.{color:#9876aa}DFLT_SCHEMA{color})){color:#cc7832};{color}
{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:

 

{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}
}
 }

 

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".

 

{color:#9876aa}node{color}.createCache({color:#cc7832}new {color}CacheConfiguration<PersonKey{color:#cc7832},
{color}Person>()
 .setName({color:#9876aa}"PERSON_1"{color})
 .setIndexedTypes(Key.{color:#cc7832}class,{color} Person.{color:#cc7832}class{color})
 .setSqlSchema(QueryUtils.{color:#9876aa}DFLT_SCHEMA{color})){color:#cc7832};{color}{color:#9876aa}node{color}.createCache({color:#cc7832}new
{color}CacheConfiguration<PersonKey{color:#cc7832}, {color}Person>()
 .setName({color:#9876aa}"PERSON_2"{color})
 .setIndexedTypes({color:#cc7832}Key.class, Person.class{color})
 .setSqlSchema(QueryUtils.{color:#9876aa}DFLT_SCHEMA{color})){color:#cc7832};{color}

 

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:

 

{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}
}
 }

 

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}
> {color:#9876aa}node{color}.createCache({color:#cc7832}new {color}CacheConfiguration<PersonKey{color:#cc7832},
{color}Person>()
>  .setName({color:#9876aa}"PERSON_1"{color})
>  .setIndexedTypes(Key.{color:#cc7832}class,{color} Person.{color:#cc7832}class{color})
>  .setSqlSchema(QueryUtils.{color:#9876aa}DFLT_SCHEMA{color})){color:#cc7832};{color}{color:#9876aa}node{color}.createCache({color:#cc7832}new
{color}CacheConfiguration<PersonKey{color:#cc7832}, {color}Person>()
>  .setName({color:#9876aa}"PERSON_2"{color})
>  .setIndexedTypes({color:#cc7832}Key.class, Person.class{color})
>  .setSqlSchema(QueryUtils.{color:#9876aa}DFLT_SCHEMA{color})){color:#cc7832};{color}
> {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:
>  
> {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}
}
>  }
>  
> 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)

Mime
View raw message