{"id":15056831,"url":"https://github.com/tosin-ogunrinde/cql-statement-builder","last_synced_at":"2026-02-22T09:40:04.024Z","repository":{"id":169686334,"uuid":"89801448","full_name":"tosin-ogunrinde/cql-statement-builder","owner":"tosin-ogunrinde","description":"Library that builds a range of CQL statements largely based on annotations from the Datastax Java Driver for Apache Cassandra.","archived":false,"fork":false,"pushed_at":"2017-05-10T06:04:57.000Z","size":113,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-29T01:27:55.471Z","etag":null,"topics":["apache-cassandra","cassandra","cql","cql-statement","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tosin-ogunrinde.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-29T17:30:14.000Z","updated_at":"2017-05-01T22:57:12.000Z","dependencies_parsed_at":"2023-06-09T10:30:32.867Z","dependency_job_id":null,"html_url":"https://github.com/tosin-ogunrinde/cql-statement-builder","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":"0.34615384615384615","last_synced_commit":"fd3e5c0cd5e37a68beee48e20e5a928aeee060e4"},"previous_names":["tosin-ogunrinde/cql-statement-builder"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/tosin-ogunrinde/cql-statement-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tosin-ogunrinde%2Fcql-statement-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tosin-ogunrinde%2Fcql-statement-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tosin-ogunrinde%2Fcql-statement-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tosin-ogunrinde%2Fcql-statement-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tosin-ogunrinde","download_url":"https://codeload.github.com/tosin-ogunrinde/cql-statement-builder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tosin-ogunrinde%2Fcql-statement-builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29708363,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T05:59:28.568Z","status":"ssl_error","status_checked_at":"2026-02-22T05:58:46.208Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-cassandra","cassandra","cql","cql-statement","java"],"created_at":"2024-09-24T21:56:45.400Z","updated_at":"2026-02-22T09:40:04.003Z","avatar_url":"https://github.com/tosin-ogunrinde.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/tosin-ogunrinde/cql-statement-builder.svg?branch=master)](https://travis-ci.org/tosin-ogunrinde/cql-statement-builder)\n[![Coverage Status](https://coveralls.io/repos/github/tosin-ogunrinde/cql-statement-builder/badge.svg?branch=master)](https://coveralls.io/github/tosin-ogunrinde/cql-statement-builder?branch=master)\n\n# CQL Statement Builder\n\nCQL Statement Builder is a Java library that automatically builds a range of [CQL](http://cassandra.apache.org/doc/latest/cql/) statements from classes/models. \nThe statements generated can then be **executed** in a preferred library or framework. CQL Statement Builder can generate CQL statements for the following commands:\n\n1. [CREATE KEYSPACE](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlCreateKeyspace.html)\n2. [CREATE TABLE](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlCreateTable.html#cqlCreateTable)\n3. [CREATE TYPE](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlCreateType.html)\n4. [DELETE](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlDelete.html)\n5. [DROP INDEX](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlDropIndex.html)\n6. [DROP KEYSPACE](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlDropKeyspace.html)\n7. [DROP TABLE](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlDropTable.html)\n8. [DROP TYPE](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlDropType.html)\n9. [SELECT *](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlSelect.html)\n10. [SELECT COUNT(*)](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlSelect.html)\n11. [USE](http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlUse.html)\n \nCQL Statement Builder can also generate the CQL statements required to create or update schemas in an Apache Cassandra cluster. \nThe schema generation feature is particularly useful because it will enable its user to focus on their code rather than worry about writing or re-writing CQL statements when a new class/model is created or when the structure of an old class/model changes.\nCQL Statement Builder makes use of the standard annotations provided by the [Datastax Java Driver for Apache Cassandra](http://docs.datastax.com/en/developer/java-driver/2.1/), except for one:\n\n@ClusteringColumnOrder: this annotation is used to indicate the order (i.e. Ascending or Descending) of the [@ClusteringColumn](http://docs.datastax.com/en/cql/3.1/cql/ddl/ddl_compound_keys_c.html). See User class example below.\n\n## CREATE KEYSPACE\nYou can build CREATE KEYSPACE CQL statements with either [SimpleStrategy or NetworkTopologyStrategy](http://docs.datastax.com/en/cql/3.1/cql/cql_reference/create_keyspace_r.html) replication strategy.\n\n### SimpleStrategy\nThe example below shows how to build a CREATE KEYSPACE CQL statement for a keyspace called foo with the replication_factor of 1.\n```\nnew CqlStatementBuildDirector().buildStatement(new CreateKeyspaceStatementBuilder(new SimpleStrategy(\"foo\", 1)));\n```\n\n### NetworkTopologyStrategy\nThe example below shows how to build a CREATE KEYSPACE CQL statement for a keyspace called foo with two data centers.\n```\nnew CqlStatementBuildDirector().buildStatement(new CreateKeyspaceStatementBuilder(new NetworkTopologyStrategy(\"foo\", getDataCenters())));\nprivate Set\u003cDataCenter\u003e getDataCenters() {\n    Set\u003cDataCenter\u003e dataCenters = new HashSet\u003c\u003e(2);\n    dataCenters.add(new DataCenter(\"datacenter1\", 2));\n    dataCenters.add(new DataCenter(\"datacenter2\", 3));\n    return dataCenters;\n}\n```\n\n## CREATE TABLE\nThe example below shows how to build a CREATE TABLE CQL statement from the User class. \n\n```\n@Table(name = \"user\")\npublic class User {\n  \n    @PartitionKey\n    private String username;\n    \n    @ClusteringColumn\n    @ClusteringColumnOrder(clusteringOrder = ClusteringOrder.ASC)\n    private String firstName;\n    \n    private String lastName;\n    \n    @Frozen\n    private Address address;\n    \n    public String getUsername() {\n        return username;\n    }\n    \n    public void setUsername(String username) {\n        this.username = username;\n    }\n\n    public String getFirstName() {\n        return firstName;\n    }\n\n    public void setFirstName(String firstName) {\n        this.firstName = firstName;\n    }\n\n    public String getLastName() {\n        return lastName;\n    }\n\n    public void setLastName(String lastName) {\n        this.lastName = lastName;\n    }\n\n    public Address getAddress() {\n        return address;\n    }\n\n    public void setAddress(Address address) {\n        this.address = address;\n    }\n}\n```\n```\n@UDT(name = \"address\")\npublic class Address {\n    private String postCode;\n    \n    public String getPostCode() {\n        return postCode;\n    }\n    \n    public void setPostCode(String postCode) {\n        this.postCode = postCode;\n    }\n}\n```\n```\nnew CqlStatementBuildDirector().buildStatement(new EntityStatementBuilderFactory(User.class).getEntityStatementBuilder());\n```\n\n## CREATE TYPE\nThe example below shows how to build a CREATE TYPE CQL statement from the Address class above. \n```\nnew CqlStatementBuildDirector().buildStatement(new EntityStatementBuilderFactory(Address.class).getEntityStatementBuilder());\n```\n\n## DELETE\nThe example below shows how to build a DELETE CQL statement from the User class above. Multiple keys can also be specified if multiple partition keys \nor clustering columns are used. \n```\nnew CqlStatementBuildDirector().buildStatement(new DeleteStatementBuilder(User.class, \"foo\"));\n```\n\n## DROP\nCQL Statement Builder can build the following DROP CQL statements:\n\n1. DROP INDEX\n2. DROP KEYSPACE\n3. DROP TABLE\n4. DROP TYPE\n\nThe example below shows how to build a DROP CQL statement for a KEYSPACE called foo.\n```\nnew CqlStatementBuildDirector().buildStatement(new DropStatementBuilder(DroppableItem.KEYSPACE, \"foo\"));\n```\n\n## SELECT *\nThe example below shows how to build a SELECT * CQL statement from the User class above. \nMultiple keys can also be specified if multiple partition keys or clustering columns are used. \n```\nnew CqlStatementBuildDirector().buildStatement(new SelectStatementBuilder(User.class, \"foo\"));\n```\n\n## SELECT COUNT(*)\nThe example below shows how to build a SELECT COUNT(*) CQL statement from the User class above. \nMultiple keys can also be specified if multiple partition keys or clustering columns are used.\n```\nnew CqlStatementBuildDirector().buildStatement(new CountStatementBuilder(User.class, \"foo\"));\n```\n\n## USE\nThe example below shows how to build a USE CQL statement for a keyspace called foo.\n\n```\nnew CqlStatementBuildDirector().buildStatement(new UseStatementBuilder(\"foo\"));\n```\n\n## SchemaStatementGenerator\nThe SchemaStatementGenerator generates the list of CREATE TABLE and CREATE TYPE CQL statements from classes annotated with UDT and Table annotations.\nThe example below shows how to generate the list of CQL statements where the classes are located in the \"com.foo.bar\" package. \nThe list of statements can be used to create or update the schemas in an Apache Cassandra cluster.\n\n```\nnew SchemaStatementGenerator(\"com.foo.bar\").generateStatements();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftosin-ogunrinde%2Fcql-statement-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftosin-ogunrinde%2Fcql-statement-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftosin-ogunrinde%2Fcql-statement-builder/lists"}