All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.archinnov.achilles.generated.manager.MultiClusteringEntity_Manager Maven / Gradle / Ivy

package info.archinnov.achilles.generated.manager;

import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.RegularStatement;
import info.archinnov.achilles.generated.dsl.MultiClusteringEntity_Delete;
import info.archinnov.achilles.generated.dsl.MultiClusteringEntity_Select;
import info.archinnov.achilles.generated.dsl.MultiClusteringEntity_Update;
import info.archinnov.achilles.generated.meta.entity.MultiClusteringEntity_AchillesMeta;
import info.archinnov.achilles.internals.dsl.crud.DeleteByPartitionWithOptions;
import info.archinnov.achilles.internals.dsl.crud.DeleteWithOptions;
import info.archinnov.achilles.internals.dsl.crud.FindWithOptions;
import info.archinnov.achilles.internals.dsl.crud.InsertJSONWithOptions;
import info.archinnov.achilles.internals.dsl.crud.InsertWithOptions;
import info.archinnov.achilles.internals.dsl.crud.UpdateWithOptions;
import info.archinnov.achilles.internals.dsl.raw.NativeQuery;
import info.archinnov.achilles.internals.dsl.raw.TypedQuery;
import info.archinnov.achilles.internals.entities.MultiClusteringEntity;
import info.archinnov.achilles.internals.options.CassandraOptions;
import info.archinnov.achilles.internals.runtime.AbstractManager;
import info.archinnov.achilles.internals.runtime.RuntimeEngine;
import info.archinnov.achilles.type.SchemaNameProvider;
import info.archinnov.achilles.validation.Validator;
import java.lang.Class;
import java.lang.Long;
import java.lang.Object;
import java.lang.String;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public final class MultiClusteringEntity_Manager extends AbstractManager {
  public final MultiClusteringEntity_AchillesMeta meta;

  public MultiClusteringEntity_Manager(final Class entityClass, final MultiClusteringEntity_AchillesMeta meta, final RuntimeEngine rte) {
    super(entityClass, meta, rte);
    this.meta = meta;
  }

  /**
   * Provide CRUD operations: 
*
    *
  • FIND BY ID
  • *
  • INSERT
  • *
  • INSERT STATIC
  • *
  • INSERT IF NOT EXISTS
  • *
  • DELETE BY ID
  • *
  • DELETE BY ID IF NOT EXISTS
  • *
  • DELETE BY PARTITION
  • *
*/ public final MultiClusteringEntity_CRUD crud() { return new MultiClusteringEntity_CRUD(); } /** * Provide DSL methods:
*
    *
  • SELECT
  • *
  • ITERATION ON SELECT
  • *
  • UPDATE
  • *
  • DELETE
  • *
*/ public final MultiClusteringEntity_DSL dsl() { return new MultiClusteringEntity_DSL(); } /** * Provide Raw query methods:
*
    *
  • Typed Queries (for SELECT only)
  • *
  • Native Queries (for any kind of statement)
  • *
*/ public final MultiClusteringEntity_RAW_QUERY raw() { return new MultiClusteringEntity_RAW_QUERY(); } public final class MultiClusteringEntity_CRUD { private Optional cassandraOptions = Optional.empty(); ; public MultiClusteringEntity_Manager.MultiClusteringEntity_CRUD withSchemaNameProvider(final SchemaNameProvider schemaNameProvider) { Validator.validateNotNull(schemaNameProvider,"The provided schemaNameProvider should not be null"); this.cassandraOptions = Optional.of(CassandraOptions.withSchemaNameProvider(schemaNameProvider)); return this; } /** * Find an entity by its complete primary key@param id partition key 'id'@param c1 clustering column 'c1'@param c2 clustering column 'c2'@return FindWithOptions */ public FindWithOptions findById(final Long id, final int c1, final int c2) { List keys = new ArrayList<>(); List encodedKeys = new ArrayList<>(); Validator.validateNotNull(id, "Partition key '%s' should not be null", "id"); keys.add(id); encodedKeys.add(MultiClusteringEntity_AchillesMeta.id.encodeFromJava(id, cassandraOptions)); Validator.validateNotNull(c1, "Partition key '%s' should not be null", "c1"); keys.add(c1); encodedKeys.add(MultiClusteringEntity_AchillesMeta.c1.encodeFromJava(c1, cassandraOptions)); Validator.validateNotNull(c2, "Partition key '%s' should not be null", "c2"); keys.add(c2); encodedKeys.add(MultiClusteringEntity_AchillesMeta.c2.encodeFromJava(c2, cassandraOptions)); final Object[] primaryKeyValues = keys.toArray(); final Object[] encodedPrimaryKeyValues = encodedKeys.toArray(); return new FindWithOptions(entityClass, meta, rte, primaryKeyValues, encodedPrimaryKeyValues, cassandraOptions); } /** * Delete an entity instance by extracting its primary keyRemark: Achilles will throw an exception if any column being part of the primary key is NULL@param an instance of MultiClusteringEntity to be delete@return DeleteWithOptions */ public DeleteWithOptions delete(final MultiClusteringEntity instance) { return deleteInternal(instance, cassandraOptions); } /** * Delete an entity using its complete primary key@param id partition key 'id'@param c1 clustering column 'c1'@param c2 clustering column 'c2'@return DeleteWithOptions */ public DeleteWithOptions deleteById(final Long id, final int c1, final int c2) { List keys = new ArrayList<>(); List encodedKeys = new ArrayList<>(); Validator.validateNotNull(id, "Partition key '%s' should not be null", "id"); keys.add(id); encodedKeys.add(MultiClusteringEntity_AchillesMeta.id.encodeFromJava(id, cassandraOptions)); Validator.validateNotNull(c1, "Partition key '%s' should not be null", "c1"); keys.add(c1); encodedKeys.add(MultiClusteringEntity_AchillesMeta.c1.encodeFromJava(c1, cassandraOptions)); Validator.validateNotNull(c2, "Partition key '%s' should not be null", "c2"); keys.add(c2); encodedKeys.add(MultiClusteringEntity_AchillesMeta.c2.encodeFromJava(c2, cassandraOptions)); final Object[] partitionKeysValues = keys.toArray(); final Object[] encodedPartitionKeyValues = encodedKeys.toArray(); return new DeleteWithOptions(entityClass, meta, rte, partitionKeysValues, encodedPartitionKeyValues, Optional.empty(), cassandraOptions); } /** * Insert this entity * * @param instance an instance of MultiClusteringEntity * @return InsertWithOptions */ public final InsertWithOptions insert(final MultiClusteringEntity instance) { return insertInternal(instance, false, cassandraOptions); } /** * Update the cassandra table with NOT NULL fields extracted from this entity * * @param instance an instance of MultiClusteringEntity * @return InsertWithOptions */ public final UpdateWithOptions update(final MultiClusteringEntity instance) { return updateInternal(instance, false, cassandraOptions); } /** * Delete a whole partition using the partition key@param id partition key 'id'@return DeleteByPartitionWithOptions */ public DeleteByPartitionWithOptions deleteByPartitionKeys(final Long id) { List keys = new ArrayList<>(); List encodedKeys = new ArrayList<>(); Validator.validateNotNull(id, "Partition key '%s' should not be null", "id"); keys.add(id); encodedKeys.add(MultiClusteringEntity_AchillesMeta.id.encodeFromJava(id, cassandraOptions)); final Object[] partitionKeys = keys.toArray(); final Object[] encodedPartitionKeys = encodedKeys.toArray(); return new DeleteByPartitionWithOptions(meta, rte, partitionKeys, encodedPartitionKeys, cassandraOptions); } /** * Insert using a JSON payload * * @json the JSON string representing an instance of MultiClusteringEntity * @return InsertJSONWithOptions */ public final InsertJSONWithOptions insertJSON(final String json) { return insertJSONInternal(json, cassandraOptions); } } public final class MultiClusteringEntity_DSL { /** * Generate a SELECT statement@return MultiClusteringEntity_Select */ public final MultiClusteringEntity_Select select() { return new MultiClusteringEntity_Select(rte, meta); } /** * Generate a DELETE statement@return MultiClusteringEntity_Delete */ public final MultiClusteringEntity_Delete delete() { return new MultiClusteringEntity_Delete(rte, meta); } /** * Generate an UPDATE statement@return MultiClusteringEntity_Update */ public final MultiClusteringEntity_Update update() { return new MultiClusteringEntity_Update(rte, meta); } } public final class MultiClusteringEntity_RAW_QUERY { /** * Execute the bound statement and map the result back into an instance of MultiClusteringEntity
* Remark: the bound statement should be a SELECT statement@param boundStatement a bound statement@return TypedQuery */ public final TypedQuery typedQueryForSelect(BoundStatement boundStatement) { return typedQueryForSelectInternal(boundStatement); } /** * Execute the prepared statement and map the result back into an instance of MultiClusteringEntity
* Remark: the prepared statement should be a SELECT statement@param preparedStatement a prepared statement@return TypedQuery */ public final TypedQuery typedQueryForSelect(PreparedStatement preparedStatement, Object... encodedBoundValues) { return typedQueryForSelectInternal(preparedStatement, encodedBoundValues); } /** * Execute the regular statement and map the result back into an instance of MultiClusteringEntity
* Remark: the regular statement should be a SELECT statement@param regularStatement a regular statement@return TypedQuery */ public final TypedQuery typedQueryForSelect(RegularStatement regularStatement, Object... encodedBoundValues) { return typedQueryForSelectInternal(regularStatement, encodedBoundValues); } /** * Execute the native bound statement@param boundStatement a bound statement@return NativeQuery */ public final NativeQuery nativeQuery(BoundStatement boundStatement) { return nativeQueryInternal(boundStatement); } /** * Execute the native prepared statement@param preparedStatement a prepared statement@return NativeQuery */ public final NativeQuery nativeQuery(PreparedStatement preparedStatement, Object... encodedBoundValues) { return nativeQueryInternal(preparedStatement, encodedBoundValues); } /** * Execute the native regular statement@param regularStatement a regular statement@return NativeQuery */ public final NativeQuery nativeQuery(RegularStatement regularStatement, Object... encodedBoundValues) { return nativeQueryInternal(regularStatement, encodedBoundValues); } } }