Uploaded image for project: 'Spring Data for Apache Cassandra'
  1. Spring Data for Apache Cassandra
  2. DATACASS-747

Identifiers starting with underscore are not quoted

    XMLWordPrintable

    Details

    • Last commented by a User:
      true

      Description

      This is a followup to DATACASS-745

      CassandraMappingContext scans all classes which are part of `@Table` marked entty and attempts to add them as persistent entity

      this includes classes which are not entities themselves (nested objects of a column which will be stored as json)

      if such class cannot be added as persistent entity context will close with error

       Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraMapping' defined in class path resource [com/example/demodata/CassConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: given string [_ent2] is not a valid quoted or unquoted identifier
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
      	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:362)
      	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:334)
      	at com.example.demodata.CassConfig$$EnhancerBySpringCGLIB$$c35308a2.cassandraMapping(<generated>)
      	at org.springframework.data.cassandra.config.AbstractCassandraConfiguration.cassandraConverter(AbstractCassandraConfiguration.java:128)
      	at com.example.demodata.CassConfig$$EnhancerBySpringCGLIB$$c35308a2.CGLIB$cassandraConverter$10(<generated>)
      	at com.example.demodata.CassConfig$$EnhancerBySpringCGLIB$$c35308a2$$FastClassBySpringCGLIB$$e7eb42b0.invoke(<generated>)
      	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
      	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
      	at com.example.demodata.CassConfig$$EnhancerBySpringCGLIB$$c35308a2.cassandraConverter(<generated>)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
      	... 107 more
      Caused by: java.lang.IllegalArgumentException: given string [_ent2] is not a valid quoted or unquoted identifier
      	at org.springframework.data.cassandra.core.cql.CqlIdentifier.<init>(CqlIdentifier.java:97)
      	at org.springframework.data.cassandra.core.cql.CqlIdentifier.of(CqlIdentifier.java:138)
      	at org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentProperty.createColumnName(BasicCassandraPersistentProperty.java:373)
      	at org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentProperty.determineColumnName(BasicCassandraPersistentProperty.java:361)
      	at org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentProperty.getColumnName(BasicCassandraPersistentProperty.java:134)
      	at org.springframework.data.cassandra.core.mapping.CassandraPersistentProperty.getRequiredColumnName(CassandraPersistentProperty.java:66)
      	at org.springframework.data.cassandra.core.mapping.CassandraPersistentPropertyComparator.compare(CassandraPersistentPropertyComparator.java:95)
      	at org.springframework.data.cassandra.core.mapping.CassandraPersistentPropertyComparator.compare(CassandraPersistentPropertyComparator.java:40)
      	at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
      	at java.base/java.util.TimSort.sort(TimSort.java:220)
      	at java.base/java.util.Arrays.sort(Arrays.java:1515)
      	at java.base/java.util.ArrayList.sort(ArrayList.java:1749)
      	at org.springframework.data.mapping.model.BasicPersistentEntity.verify(BasicPersistentEntity.java:430)
      	at org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentEntity.verify(BasicCassandraPersistentEntity.java:157)
      	at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:377)
      	at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.addPersistentEntity(CassandraMappingContext.java:308)
      	at java.base/java.util.Collections$SingletonSet.forEach(Collections.java:4797)
      	at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:548)
      	at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:506)
      	at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:705)
      	at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:374)
      	at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.addPersistentEntity(CassandraMappingContext.java:308)
      	at java.base/java.util.Collections$SingletonSet.forEach(Collections.java:4797)
      	at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:548)
      	at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:506)
      	at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:705)
      	at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:374)
      	at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.addPersistentEntity(CassandraMappingContext.java:308)
      	at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:323)
      	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
      	at org.springframework.data.mapping.context.AbstractMappingContext.initialize(AbstractMappingContext.java:452)
      	at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.initialize(CassandraMappingContext.java:121)
      	at org.springframework.data.mapping.context.AbstractMappingContext.afterPropertiesSet(AbstractMappingContext.java:444)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
      	... 127 more

       

      sample

       @Table
      @Data
      public class SimpleEntity {
          @Id String id;
      
          @CassandraType(type = DataType.Name.TEXT)
          ComplexObject complexObject;
      }
      
      @Data
      class ComplexObject {
          String value1;
          NotPersistentEntity value2;
      }
      
      @Data
      class NotPersistentEntity{
          String _ent1;
          String _ent2;
      }

        Attachments

          Activity

            People

            Assignee:
            mp911de Mark Paluch
            Reporter:
            L.Swiatek Łukasz Świątek
            Last updater:
            Mark Paluch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              25 weeks, 4 days ago