-
Notifications
You must be signed in to change notification settings - Fork 0
Primary Key Auto generation
Kundera allows you to store objects with generated primary key value in NoSQL. (Currently supported for MongoDB, HBase, Cassandra and Redis).
To enable this feature, Entities must have @GeneratedValue annotation along with @Id annotation.
Kundera supports following types of generation strategies:
- AUTO
- SEQUENCE
- TABLE
Only supported for MongoDB. To generate primary key using auto-generation strategy, id attribute in entity must be of String type.
In order to use Auto-generation strategy, set strategy to GenerationType.AUTO. (This is default in case you don't specify any strategy).
@Entity
@Table(name = "USER", schema = "keyspace-Name@pu-name")
public class User
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private String id;
@Column
private String name;
// getter and setter
}
Only supported for Redis client. To generate primary key using Sequence generation strategy, Id attribute in entity must be one of java's numberic types.
In order to use Sequence-generation strategy, set strategy to GenerationType.SEQUENCE. Rest attributes are self-explanatory and have their meanings derived from JPA.
@Entity
@Table(name = "USER", schema = "keyspace-Name@pu-name")
public class User
{
@Id
@SequenceGenerator(name = "seq_gen", allocationSize = 20, initialValue = 80)
@GeneratedValue(generator = "seq_gen", strategy = GenerationType.SEQUENCE)
private String id;
@Column
private String name;
// getter and setter
}
OR
@Entity
@Table(name = "USER", schema = "keyspace-Name@pu-name")
public class User
{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private String id;
@Column
private String name;
// getter and setter
}
Only supported for HBase and Cassandra clients. To generate primary key using Table generation strategy, Id attribute in entity must be one of java's numberic types.
In order to use Table-generation strategy, set strategy to GenerationType.TABLE. Rest attributes are self-explanatory and have their meanings derived from JPA.
@Entity
@Table(name = "USER", schema = "keyspace-Name@pu-name")
public class User
{
@Id
@TableGenerator(name = "id_gen", allocationSize = 30, initialValue = 100)
@GeneratedValue(generator = "id_gen", strategy = GenerationType.TABLE)
private String id;
@Column
private String name;
// getter and setter
}
OR
@Entity
@Table(name = "USER", schema = "keyspace-Name@pu-name")
public class User
{
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private String id;
@Column
private String name;
// getter and setter
}
This is currently not supported by Kundera.
-
Datastores Supported
- Releases
-
Architecture
-
Concepts
-
Getting Started in 5 minutes
-
Features
- Object Mapper
- Polyglot Persistence
- Queries Support
- JPQL (JPA Query Language)
- Native Queries
- Batch insert update
- Schema Generation
- Primary Key Auto generation
- Transaction Management
- REST Based Access
- Geospatial Persistence and Queries
- Graph Database Support
-
Composite Keys
-
No hard annotation for schema
-
Support for Mapped superclass
-
Object to NoSQL Data Mapping
-
Cassandra's User Defined Types and Indexes on Collections
-
Support for aggregation
- Scalar Queries over Cassandra
- Connection pooling using Kundera Cassandra
- Configuration
- [Kundera with Couchdb] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with--Couchdb)
- [Kundera with Elasticsearch] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Elasticsearch)
- [Kundera with HBase] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-HBase)
- [Kundera with Kudu] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Kudu)
- [Kundera with MongoDB] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-MongoDB)
- [Kundera with OracleNoSQL] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-OracleNoSQL)
- [Kundera with Redis] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-over-Redis)
- [Kundera with Spark] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Spark)
-
Extend Kundera
- Sample Codes and Examples
- [Blogs and Articles] (https://github.com/impetus-opensource/Kundera/wiki/Blogs--and-Articles)
-
Tutorials
* Kundera with Openshift
* Kundera with Play Framework
* Kundera with GWT
* Kundera with JBoss
* Kundera with Spring
-
Performance
-
Troubleshooting
-
FAQ
- Production deployments
- Feedback