{"id":13563481,"url":"https://github.com/mridang/jacksandra","last_synced_at":"2026-04-24T12:32:01.056Z","repository":{"id":139542963,"uuid":"361383104","full_name":"mridang/jacksandra","owner":"mridang","description":"A Jackson-based automatic schema-generator for Cassandra","archived":false,"fork":false,"pushed_at":"2022-07-28T17:34:15.000Z","size":369,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-13T02:02:59.310Z","etag":null,"topics":["cassandra","cql","jackson","schema-gen"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/mridang.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}},"created_at":"2021-04-25T09:19:09.000Z","updated_at":"2021-11-04T16:56:33.000Z","dependencies_parsed_at":"2024-01-14T03:47:29.767Z","dependency_job_id":"9556938e-7411-47bd-af71-9be9489f85c4","html_url":"https://github.com/mridang/jacksandra","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/mridang/jacksandra","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fjacksandra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fjacksandra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fjacksandra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fjacksandra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mridang","download_url":"https://codeload.github.com/mridang/jacksandra/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mridang%2Fjacksandra/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32223873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T10:26:35.452Z","status":"ssl_error","status_checked_at":"2026-04-24T10:25:27.643Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["cassandra","cql","jackson","schema-gen"],"created_at":"2024-08-01T13:01:19.756Z","updated_at":"2026-04-24T12:32:01.041Z","avatar_url":"https://github.com/mridang.png","language":"Scala","funding_links":[],"categories":["Scala"],"sub_categories":[],"readme":"# Jacksandra\n\nJacksandra (aptly named) is a Jackson-based module for working with Cassandra rows. At the time of writing, Jacksandra can only be used for schema generation\nusing Jackson, but a future version will add support for ser-deser to types to the corresponding \"row\" objects.\n\n## Installation\n\nUnfortunately, Jacksandra is not available in any public Maven repositories except the GitHub Package Registry. For more information on how to install packages\nfrom the GitHub Package\nRegistry, [https://docs.github.com/en/packages/guides/configuring-gradle-for-use-with-github-packages#installing-a-package][see the GitHub docs]\n\n## Usage\n\nAs the Datastax Mappers provide no support for schemagen, this module is supposed to be a drop-in module to augment existing functionality provided by the\nexisting Datastax libraries.\n\nAssume you have the following bean for which you would like to generate the schema:\n\n```java\nimport java.util.Date;\n\nimport com.datastax.oss.driver.api.mapper.annotations.CqlName;\nimport com.datastax.oss.driver.api.mapper.annotations.Entity;\nimport com.datastax.oss.driver.api.mapper.annotations.PartitionKey;\nimport com.mridang.jacksandra.annotations.OrderedClusteringColumn;\nimport com.mridang.jacksandra.types.FrozenList;\n\n@Entity(defaultKeyspace = \"mykeyspace\")\n@CqlName(\"brandsimilarities\")\npublic class BrandSimilarities {\n\n    @SuppressWarnings(\"DefaultAnnotationParam\")\n    @PartitionKey(0)\n    @CqlName(\"brand\")\n    public String brand;\n\n    @SuppressWarnings(\"DefaultAnnotationParam\")\n    @OrderedClusteringColumn(isAscending = false, value = 0)\n    @CqlName(\"createdat\")\n    public Date createdAt;\n\n    @OrderedClusteringColumn(isAscending = true, value = 1)\n    @CqlName(\"skuid\")\n    public String skuId;\n\n    @CqlName(\"related\")\n    public FrozenList\u003cRelation\u003e productRelations;\n\n    @CqlName(\"relation\")\n    public static class Relation {\n\n        @CqlName(\"brand\")\n        public String brand;\n\n        @CqlName(\"skuid\")\n        public String skuId;\n\n        @CqlName(\"score\")\n        public Float score;\n    }\n}\n```\n\nTo generate the schema for the bean described above, you would run:\n\n```scala\n    val mapper = new CassandraJavaBeanMapper[BrandSimilarities]()\nval createSchema: String = mapper.generateMappingProperties\n```\n\nto yield the DDL:\n\n```sql\nCREATE \n  TYPE \nIF NOT \nEXISTS relation \n     ( score FLOAT\n     , skuid TEXT\n     , brand TEXT\n     );\n\nCREATE \n TABLE \nIF NOT \nEXISTS brandsimilarities \n     ( brand TEXT\n     , shardkey TINTINT\n     , createdat TEXT\n     , skuid TEXT\n     , related LIST\u003cFROZEN\u003crelation\u003e\u003e\n     , PRIMARY KEY\n       ( ( brand\n         , shardkey\n          )\n       , createdat\n       , skuid\n       )\n    )\n  WITH CLUSTERING \n ORDER \n    BY \n     ( createdat DESC\n     , skuid ASC\n     );\n```\n\n### Types\n\nThe follow exhaustive list outlines all the CQL types along with the JVM counterparts.\n\n| CQL         |           Java                             |          Scala         |\n|-------------|--------------------------------------------|-----------------------:|\n| `BOOLEAN`   | `java.lang.Boolean`                        |                        |\n| `TEXT`      | `java.lang.String`                         |                        |\n| `VARCHAR`   | `java.lang.String`                         |                        |\n| `FLOAT`     | `java.lang.Float`                          |                        |\n| `DOUBLE`    | `java.lang.Double`                         |                        |\n| `BIGINT`    | `java.lang.Long`                           |                        |\n| `INT`       | `java.lang.Integer`                        |                        |\n| `SMALLINT`  | `java.lang.Short`                          |                        |\n| `TINYINT`   | `java.lang.Byte`                           |                        |\n| `VARINT`    | `java.math.BigInteger`                     |                        |\n| `DECIMAL`   | `java.math.BigDecimal`                     |                        |\n| `ASCII`     | `com.mridang.jacksandra.types.CqlAscii`    |                        |\n| `INET`      | `java.net.InetAddress`                     |                        |\n| `UUID`      | `java.util.UUID`                           |                        |\n| `TIMEUUID`  | `com.mridang.jacksandra.types.CqlTimeUUID` |                        |\n| `DURATION`  | `com.mridang.jacksandra.types.CqlDuration` |                        |\n|             | `java.time.Duration`                       |                        |\n| `BLOB`      | `com.mridang.jacksandra.types.CqlBlob`     |                        |\n| `DATE`      | `java.time.LocalDate`                      |                        |\n| `TIME`      | `java.time.LocalTime`                      |                        |\n| `TIMESTAMP` | `java.sql.Timestamp`                       |                        |\n|             | `java.util.Instant`                        |                        |\n|             | `java.time.LocalDateTime`                  |                        |\n\n### Collections\n\nJacksandra supports all collection types including the \"frozen\" variants. Any property that derives from `java.util.Collection` will be mapped as a `LIST` data\ntype. If you require a \"frozen\" representation, use any collection type simply implement the `Frozen` interface.\n\n#### Lists\n\nWhen using Java: any property that derives from `java.util.List` will be mapped as a `LIST` data type. If you require a \"frozen\" representation,\nuse `FrozenList` when possible.\n\nWhen using Scala: any property that derives from `scala.collection.mutable.List`\nwill bbe mapped as `LIST` data type. If you require a \"frozen\" representation, use `scala.collection.immutable.List` when possible.\n\n#### Sets\n\nWhen using Java: any property that derives from `java.util.Set` will be mapped as a `SET` data type. If you require a \"frozen\" representation, use `FrozenSet`\nwhen possible.\n\nWhen using Scala: any property that derives from `scala.collection.mutable.Set`\nwill bbe mapped as `LIST` data type. If you require a \"frozen\" representation, use `scala.collection.immutable.Set` when possible.\n\n### Maps\n\nAnWhen using Java: any property that derives from `java.util.Map` will be mapped as a `MAP` data type.\n\nWhen using Scala: any property that derives from `scala.collection.mutable.Map`\nwill bbe mapped as `MAP` data type.\n\n### Tuples\n\nAt the time of writing, there is no support for tuples. See https://github.com/mridang/jacksandra/issues/4\n\n### Partition Keys\n\nUse the `@PartitionKey` annotation to denote the partition keys.\n\nOne more properties of a schema must have a `@PartitionKey` annotation.\n\n### Clustering Columns\n\nUse the `@ClusteringColumn` annotation or the `@OrderedClusteringColumn` to denote that a column is a part of the clustering key. The\ncustom  `@OrderedClusteringColumn` annotation has been added as the `com.datastax.oss.driver.api.mapper.annotations.ClusteringColumn` annotation provided by the\nDatastax libraries don't support specifying the clustering order.\n\nA schema may or may not have a `@OrderedClusteringColumn` annotation or the `@ClusteringColumn`\nannotation at all static columns are optional.\n\n### Static Columns\n\nUse the `@StaticColumn` annotation to denote static columns. The custom `@StaticColumn`\nannotation is provided as there doesn't seem to be corresponding annotation in the Datastax libraries.\n\nA schema may or may not have a `@StaticColumn` annotation at all static columns are optional.\n\n### Adding custom types\n\nYou can easily add support for custom types.\n\n## Usage (Spark)\n\n```scala\n@CqlName(\"mytable\")\nclass MyBean(@PartitionKey val ssn: Int, val firstName: String, val lastName: String)\n  extends Serializable\n```\n\n### Writing\n\nIn order to persist an RDD into a Cassandra table, you can use the following. The connector must be provided as an implicit variable.\n\nThis method does not create the keyspace, the table or any types. The name of the table is read from the `CqlName` annotation on the entity.\n\n```scala\nimport com.datastax.spark.connector.plus.toRDDFunctions\n\nimplicit val connector: CassandraConnector = CassandraConnector(sc.getConf)\nimplicit val rwf: RowWriterFactory[MyBean] = new CassandraJsonRowWriterFactory[MyBean]\n\nval inputRDD: RDD[MyBean] = RandomRDD[MyBean](sc).of(randomItemsCount)\ninputRDD.saveToCassandra(\"mykeyspace\")\n```\n\n### Reading\n\nIn order to read a Cassandra table into an RDD, you can use the following. The connector must be provided as an implicit variable.\n\nThis method does not create the keyspace, the table or any types. The name of the table is read from the `CqlName` annotation on the entity.\n\n```scala\nimport com.datastax.spark.connector.plus.toSparkContextFunctions\n\nimplicit val connector: CassandraConnector = CassandraConnector(sc.getConf)\n\nval inputRDD: RDD[MyBean] = sc.cassandraTable[MyBean](\"mykeyspace\")\n```\n\n## License\n\nApache-2.0 License\n\nCopyright (c) 2021 Mridang Agarwalla\n\n[see the GitHub docs]: https://docs.github.com/en/packages/guides/configuring-gradle-for-use-with-github-packages#installing-a-package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmridang%2Fjacksandra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmridang%2Fjacksandra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmridang%2Fjacksandra/lists"}