2323import com .datastax .oss .driver .api .core .CqlSession ;
2424import com .datastax .oss .driver .api .core .cql .SimpleStatement ;
2525import com .datastax .oss .driver .api .core .servererrors .InvalidQueryException ;
26+ import com .datastax .oss .driver .api .mapper .annotations .ClusteringColumn ;
2627import com .datastax .oss .driver .api .mapper .annotations .Dao ;
2728import com .datastax .oss .driver .api .mapper .annotations .DaoFactory ;
2829import com .datastax .oss .driver .api .mapper .annotations .DaoKeyspace ;
@@ -68,6 +69,7 @@ public static void setup() {
6869 Arrays .asList (
6970 "CREATE TABLE product_simple(id uuid PRIMARY KEY, description text, unmapped text)" ,
7071 "CREATE TABLE product_simple_missing_p_k(id uuid PRIMARY KEY, description text, unmapped text)" ,
72+ "CREATE TABLE product_simple_missing_clustering_column(id uuid PRIMARY KEY, description text, unmapped text)" ,
7173 "CREATE TYPE dimensions_with_incorrect_name(length int, width int, height int)" ,
7274 "CREATE TYPE dimensions_with_incorrect_name_schema_hint_udt(length int, width int, height int)" ,
7375 "CREATE TYPE dimensions_with_incorrect_name_schema_hint_table(length int, width int, height int)" ,
@@ -203,6 +205,16 @@ public void should_throw_when_table_is_missing_PKs() {
203205 sessionRule .keyspace ()));
204206 }
205207
208+ @ Test
209+ public void should_throw_when_table_is_missing_clustering_column () {
210+ assertThatThrownBy (() -> mapper .productSimpleMissingClusteringColumn (sessionRule .keyspace ()))
211+ .isInstanceOf (IllegalArgumentException .class )
212+ .hasMessageContaining (
213+ String .format (
214+ "The CQL ks.table: %s.product_simple_missing_clustering_column has missing Clustering columns: [not_existing_clustering_column] that are defined in the entity class: com.datastax.oss.driver.mapper.SchemaValidationIT.ProductSimpleMissingClusteringColumn" ,
215+ sessionRule .keyspace ()));
216+ }
217+
206218 @ Mapper
207219 public interface InventoryMapper {
208220 @ DaoFactory
@@ -231,6 +243,10 @@ ProductWithIncorrectUdtSchemaHintTableDao productWithIncorrectUdtSchemaHintTable
231243
232244 @ DaoFactory
233245 ProductSimpleMissingPKDao productSimpleMissingPKDao (@ DaoKeyspace CqlIdentifier keyspace );
246+
247+ @ DaoFactory
248+ ProductSimpleMissingClusteringColumnDao productSimpleMissingClusteringColumn (
249+ @ DaoKeyspace CqlIdentifier keyspace );
234250 }
235251
236252 @ Dao
@@ -268,7 +284,7 @@ public interface ProductSimpleDao {
268284 ProductSimple findById (UUID productId );
269285 }
270286
271- @ Dao ()
287+ @ Dao
272288 public interface ProductSimpleDaoValidationDisabledDao {
273289
274290 @ Select
@@ -288,6 +304,12 @@ public interface ProductSimpleMissingPKDao {
288304 ProductSimpleMissingPK findById (UUID productId );
289305 }
290306
307+ @ Dao
308+ public interface ProductSimpleMissingClusteringColumnDao {
309+ @ Select
310+ ProductSimpleMissingClusteringColumn findById (UUID productId );
311+ }
312+
291313 @ Entity
292314 public static class ProductCqlTableMissing {
293315 @ PartitionKey private UUID id ;
@@ -318,6 +340,30 @@ public void setIdNotPresent(UUID idNotPresent) {
318340 }
319341 }
320342
343+ @ Entity
344+ public static class ProductSimpleMissingClusteringColumn {
345+ @ PartitionKey private UUID id ;
346+ @ ClusteringColumn private Integer notExistingClusteringColumn ;
347+
348+ public ProductSimpleMissingClusteringColumn () {}
349+
350+ public UUID getId () {
351+ return id ;
352+ }
353+
354+ public void setId (UUID id ) {
355+ this .id = id ;
356+ }
357+
358+ public Integer getNotExistingClusteringColumn () {
359+ return notExistingClusteringColumn ;
360+ }
361+
362+ public void setNotExistingClusteringColumn (Integer notExistingClusteringColumn ) {
363+ this .notExistingClusteringColumn = notExistingClusteringColumn ;
364+ }
365+ }
366+
321367 @ Entity
322368 public static class ProductSimple {
323369 @ PartitionKey private UUID id ;
0 commit comments