Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2012 Clarion Media, LLC
   * 
   * 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 com.clarionmedia.infinitum.orm;
 
 

This interface specifies methods for interacting with a datastore. This is not typically used directly but allows for greater testability.

Author(s):
Tyler Treat
Version:
1.0 02/15/12
 
 public interface DatastoreOperations {

Constructs a new com.clarionmedia.infinitum.orm.criteria.Criteria for the given entity java.lang.Class.

Parameters:
entityClass the Class to create the Criteria for
Returns:
new Criteria
 
 	<T> Criteria<T> createCriteria(Class<T> entityClass);

Persists the given java.lang.Object to the database. This method is not idempotent, meaning if the record already exists, a new one will attempt to persist.

Parameters:
model Object to persist to the database
Returns:
the row ID of the newly inserted record, or -1 if the insert failed
Throws:
com.clarionmedia.infinitum.exception.InfinitumRuntimeException if the model is marked transient
 
 	long save(Object modelthrows InfinitumRuntimeException;

Updates the given java.lang.Object in the database.

Parameters:
model Object to update in the database
Returns:
true if the updated succeeded, false if it failed
Throws:
com.clarionmedia.infinitum.exception.InfinitumRuntimeException if the model is marked transient
 
 	boolean update(Object modelthrows InfinitumRuntimeException;

Deletes the given java.lang.Object from the database if it exists.

Parameters:
model Object to delete from the database
Returns:
true if the record was deleted, false otherwise
Throws:
com.clarionmedia.infinitum.exception.InfinitumRuntimeException if the model is marked transient
 
 	boolean delete(Object modelthrows InfinitumRuntimeException;

Persists the given java.lang.Object to the database, or, if it already exists, updates the record.

Parameters:
model Object to save or update in the database
Returns:
the row ID of the newly inserted row, 0 if the row was updated, or -1 if the operation failed
Throws:
com.clarionmedia.infinitum.exception.InfinitumRuntimeException if the model is marked transient
 
 	long saveOrUpdate(Object modelthrows InfinitumRuntimeException;

Returns an instance of the given persistent model java.lang.Class as identified by the specified primary key(s) or null if no such entity exists.

Parameters:
c the Class of the persistent instance to load
id the primary key value of the persistent instance to load
Returns:
the persistent instance
Throws:
com.clarionmedia.infinitum.exception.InfinitumRuntimeException if the specified Class is marked transient
java.lang.IllegalArgumentException if an incorrect number of primary keys is provided
Executes the given SQL non-query on the database, meaning no result is expected.

Parameters:
sql the SQL query to execute
Throws:
com.clarionmedia.infinitum.orm.exception.SQLGrammarException if the SQL was formatted incorrectly
	void execute(String sqlthrows SQLGrammarException;
New to GrepCode? Check out our FAQ X