Skip to content
This repository
branch: master
Otávio Santana March 31, 2014
executable file 404 lines (364 sloc) 11.496 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
/*
* Copyright 2013 Otávio Gonçalves de Santana (otaviojava)
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.easycassandra.persistence.cassandra.spring;

import java.util.List;

import org.easycassandra.persistence.cassandra.PersistenceBuilder;

import com.datastax.driver.core.ConsistencyLevel;



/**
* Base to cassandra databases, the interface has all resources that may use in
* Cassandra database.
* @author otaviojava
*/
public interface CassandraTemplate extends PersistenceBuilder {
    /**
* saves the object.
* @param entity
* the entity
* @param <T>
* kind of class
* @return the entity saved
*/
    <T> T save(T entity);

    /**
* saves the objects with consistency level.
* @param entity
* the entity
* @param consistency
* the consistency
* @param <T>
* kind of class
* @return the entity saved
*/
    <T> T save(T entity, ConsistencyLevel consistency);

    /**
* save a list of objects.
* @param entities
* the entities
* @param <T>
* kind of class
* @return the entities saved
*/
    <T> Iterable<T> save(Iterable<T> entities);

    /**
* saves a list of objects with consistency level.
* @param entities
* the entities
* @param consistency
* the consistency
* @param <T>
* kind of class
* @return the entities saved
*/
    <T> Iterable<T> save(Iterable<T> entities, ConsistencyLevel consistency);

    /**
* delete an entity.
* @param entity
* the entity
* @param <T>
* kind of class
*/
    <T> void delete(T entity);

    /**
* delete an entity with consistence level.
* @param entity
* the entity
* @param consistency
* the consistency
* @param <T>
* kind of class
*/
    <T> void delete(T entity, ConsistencyLevel consistency);

    /**
* delete an interable os entities.
* @param entities
* the entities
* @param <T>
* kind of class
*/
    <T> void delete(Iterable<T> entities);

    /**
* delete an interable os entities with consistency level.
* @param entities
* the entities
* @param consistency
* the consistency
* @param <T>
* kind of class
*/
    <T> void delete(Iterable<T> entities, ConsistencyLevel consistency);

    /**
* delete an object from a key.
* @param key
* the key
* @param entity
* the entity
* @param <K>
* kind of key
*/
    <K> void delete(K key, Class<?> entity);

    /**
* delete an object from a key with consistency level.
* @param key
* the key
* @param entity
* the entity
* @param consistency
* the consistency
* @param <K>
* kind of key
*/
    <K> void delete(K key, Class<?> entity, ConsistencyLevel consistency);

    /**
* delete objects from keys.
* @param keys
* the keys
* @param entity
* the entity
* @param <K>
* kind of key
* @param <T>
* kind of class
*/
    <K, T> void delete(Iterable<K> keys, Class<T> entity);

    /**
* delete objects from keys with consistency level.
* @param keys
* the keys
* @param entity
* the entity
* @param consistency
* the consitency
* @param <K>
* kind of key
* @param <T>
* kind of class
*/
    <K, T> void delete(Iterable<K> keys, Class<T> entity,
            ConsistencyLevel consistency);

    /**
* Remove all objects in column family.
* @param entity
* the entity
* @param <T>
* kind of class
*/
    <T> void deleteAll(Class<T> entity);

    /**
* update the object.
* @param entity
* the entity
* @param <T>
* kind of class
* @return the object updated
*/
    <T> T update(T entity);

    /**
* update the object.
* @param entity
* the entity
* @param consistency
* the consitency
* @param <T>
* kind of class
* @return the object updated
*/
    <T> T update(T entity, ConsistencyLevel consistency);

    /**
* update these objects.
* @param entities
* the entities
* @param <T> kind of object
* @return the entities updated
*/
    <T> Iterable<T> update(Iterable<T> entities);

    /**
* update these objects with consistency level.
* @param <T> kind of object
* @param entities the entities
* @param consistency the consistency
* @return the entities updated
*/
    <T> Iterable<T> update(Iterable<T> entities, ConsistencyLevel consistency);

    /**
* find one entity by key.
* @param <T> kind of object
* @param <K> kind of key
* @param key the key
* @param entity the entity
* @return object by key, if does find will return null
*/
    <T, K> T findOne(K key, Class<T> entity);

    /**
* find one entity by key.
* @param <T> kind of object
* @param <K> kind of key
* @param key the key
* @param entity the entity
* @param consistency the consistency
* @return object by key, if does find will return null
*/
    <T, K> T findOne(K key, Class<T> entity, ConsistencyLevel consistency);

    /**
* return all objects.
* @param <T> kind of object
* @param <K> kind of key
* @param keys the keys
* @param entity the entity
* @return find all.
*/
    <T, K> List<T> findAll(Iterable<K> keys, Class<T> entity);

    /**
* return all objects.
* @param <T> kind of object
* @param <K> kind of key
* @param keys the keys
* @param entity the entity
* @param consistency the consistency
* @return find all.
*/
    <T, K> List<T> findAll(Iterable<K> keys, Class<T> entity,
            ConsistencyLevel consistency);

    /**
* returns all entities.
* @param <T> kind of object
* @param entity the entity
* @return all object on cassandra
*/
    <T> List<T> findAll(Class<T> entity);

    /**
* returns all entities.
* @param <T> kind of object
* @param entity the entity
* @param consistency the consistency
* @return all object on cassandra
*/
    <T> List<T> findAll(Class<T> entity, ConsistencyLevel consistency);

    /**
* return by index.
* @param <T> kind of object
* @param <I> kind of index
* @param index the index
* @param entity the entity
* @param columnName the columnName
* @return entities by index
*/
    <T, I> List<T> findByIndex(String columnName, I index, Class<T> entity);
    /**
* return by index.
* @param <T> kind of object
* @param <I> kind of index
* @param index the index
* @param entity the entity
* @param columnName the columnName
* @param consistency the consistency
* @return entities by index
*/
    <T, I> List<T> findByIndex(String columnName, I index, Class<T> entity,
            ConsistencyLevel consistency);

    /**
* Find by key and annotated index.
* @param key the key
* @param index the index
* @param entity the entity
* @author Nenita Casuga
* @param <T> kind of object
* @param <I> kind of index
* @since 10/31/2013
* @return entities by index
*/
    <T, I> List<T> findByKeyAndIndex(Object key, I index, Class<T> entity);

    /**
* Find by key and annotated index.
* @param key the key
* @param index the index
* @param entity the entity
* @author Nenita Casuga
* @param <T> kind of object
* @param <I> kind of index
* @param consistency the
* @since 10/31/2013
* @return entities by index
*/
    <T, I> List<T> findByKeyAndIndex(Object key, I index, Class<T> entity,
            ConsistencyLevel consistency);

    /**
* Find by key and annotated index.
* @param key the key
* @param entity the entity
* @author Nenita Casuga
* @param <T> kind of object
* @param <I> kind of index
* @param exclusive the exclusive
* @param indexStart the indexStart
* @param indexEnd the indexEnd
* @since 10/31/2013
* @return entities by index
*/
    <T, I> List<T> findByKeyAndIndexRange(Object key, I indexStart, I indexEnd,
            boolean exclusive, Class<T> entity);

    /**
* Find by key and annotated index.
* @param key the key
* @param entity the entity
* @author Nenita Casuga
* @param <T> kind of object
* @param <I> kind of index
* @param exclusive the exclusive
* @param indexStart the indexStart
* @param indexEnd the indexEnd
* @param consistency the consistency
* @since 10/31/2013
* @return entities by index
*/
    <T, I> List<T> findByKeyAndIndexRange(Object key, I indexStart, I indexEnd,
            boolean exclusive, Class<T> entity, ConsistencyLevel consistency);

    /**
* verify if exist.
* @param <T> kind of object
* @param <K> kind of key
* @param key the key
* @param entity the entity
* @return if exist
*/
    <K, T> boolean exist(K key, Class<T> entity);
    /**
* verify if exist.
* @param <T> kind of object
* @param <K> kind of key
* @param key the key
* @param entity the entity
* @param consistency the consistency
* @return if exist
*/
    <K, T> boolean exist(K key, Class<T> entity, ConsistencyLevel consistency);

    /**
* execute a query.
* @param query the query
*/
    void executeUpdate(String query);

    /**
* counts a number of rows in column family.
* @param bean the bean
* @param <T> kind of entity
* @return the value of entities on column family
*/
    <T> long count(Class<T> bean);
    /**
* counts a number of rows in column family.
* @param bean the bean
* @param <T> kind of entity
* @param consistency the consistency
* @return the value of entities on column family
*/
    <T> long count(Class<T> bean, ConsistencyLevel consistency);

}
Something went wrong with that request. Please try again.