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

Take in account the @Indexed attributes when creating a table

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      I'm looking to enable the index creation on the table creation, but I can't get it to work.
      After looking at the documentation http://docs.spring.io/spring-data/cassandra/docs/1.5.0.RC1/reference/html/#mapping.usage-annotations, @Indexed doesn't appear in the list even though it's in org.springframework.data.cassandra.mapping package and its javadoc says:

      Identifies a secondary index in the table on a single, non-key column.
      
      The name of the index. If {@literal null} or empty, then the index name will be generated by Cassandra and will be
      unknown unless column metadata is used to discover the generated index name.
      

      Which could let think Spring Data Cassandra handles the index creation.

      Here's my model:

      @Table("my_object")
      public class MyObject {
      
          @PrimaryKeyColumn(name = "e", type = PrimaryKeyType.PARTITIONED, ordinal = 1)
          @CassandraType(type = DataType.Name.TEXT)
          private MyEnum e;
      
          @PrimaryKeyColumn(name = "id", type = PrimaryKeyType.CLUSTERED, ordinal = 2)
          @CassandraType(type = DataType.Name.UUID)
          private UUID id;
      
          @Column("value")
          @Indexed("value_idx")
          private String value;
      
          // Getters & setters omitted
      }
      

      Here is the description of the table created:

      CREATE TABLE test.my_object (
          e text,
          id uuid,
          value text,
          PRIMARY KEY (e, id)
      ) WITH CLUSTERING ORDER BY (id ASC)
      ...
      

      I would have expected:

      CREATE TABLE test.my_object (
          e text,
          id uuid,
          value text,
          PRIMARY KEY (e, id)
      ) WITH CLUSTERING ORDER BY (id ASC)
      ...
      CREATE INDEX value_idx ON test.my_object (value);
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mp911de Mark Paluch
              Reporter:
              Marc P. Marc Pynaert
              Last updater:
              Mark Paluch
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 10 weeks, 2 days ago