Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2013 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.sql;
 
 import java.util.List;
 

SqlBuilder is used to dynamically construct SQL strings for table generation and queries at runtime.

Author(s):
Tyler Treat
Version:
1.0.6 04/02/13
Since:
1.0
 
 public interface SqlBuilder {

Creates the model tables for the application in the SQLite database as configured in infinitum.cfg.xml and returns the numbers of tables created.

Parameters:
dbHelper the SqliteDbHelper encapsulating the InfinitumContext for this application
Returns:
number of tables created
Throws:
com.clarionmedia.infinitum.orm.exception.ModelConfigurationException if table(s) cannot be created due to a misconfigured model. For example, a model that does not contain any persistent Fields
com.clarionmedia.infinitum.context.exception.InfinitumConfigurationException if domain classes have not been properly configured in infinitum.cfg.xml
 
 	int createTables(SqliteDbHelper dbHelper)
Drops the model tables from the application's SQLite database and returns the number of tables dropped.

Parameters:
dbHelper the SqliteDbHelper encapsulating the InfinitumContext for this application
Returns:
number of tables dropped
 
 	int dropTables(SqliteDbHelper dbHelper);

Generates a SQL query java.lang.String from the given com.clarionmedia.infinitum.orm.criteria.Criteria.

Parameters:
criteria the Criteria to build the SQL query from
Returns:
SQL query
 
 	String createQuery(Criteria<?> criteria);

Generates a SQL query java.lang.String from the given com.clarionmedia.infinitum.orm.criteria.Criteria for counting records.

Parameters:
criteria the Criteria to build the SQL query from
Returns:
SQL query
 
 	String createCountQuery(Criteria<?> criteria);

Generates a SQL query java.lang.String from the given com.clarionmedia.infinitum.orm.relationship.ManyToManyRelationship which retrieves rows of the given direction type which are associated with the given ID.

For example, assume you have the models Foo and Bar which have a many-to-many association and are mapped to the tables foo and bar respectively with the relationships being stored in foobar. Calling createManyToManyJoinQuery(rel, 42, Bar.class) would generate a query that would retrieve all records of Bar associated with the instance of Foo which has an ID of 42.

Parameters:
rel the com.clarionmedia.infinitum.orm.relationship.ManyToManyRelationship containing the association being queried
id the ID in which the associated records are linked with
direction the direction the relationship is being queried in, returning records of this java.lang.Class
Returns:
SQL query
Throws:
com.clarionmedia.infinitum.exception.InfinitumRuntimeException if the direction Class is not a part of the given ManyToManyRelationship
			Serializable idClass<?> direction)
Generates a SQL java.lang.String consisting of the query for deleting stale many-to-many relationships.

For example: DELETE FROM foo_bar WHERE foo_id = 42 AND bar_id NOT IN (8, 12, 38) . This query will be used to clear relationships which no longer exist.

Parameters:
rel the com.clarionmedia.infinitum.orm.relationship.ManyToManyRelationship for this relationship query
model the model containing the relationship
relatedKeys the java.util.List containing the IDs of entities which are still related
Returns:
String containing the SQL query
			Object modelList<SerializablerelatedKeys);

Generates a SQL java.lang.String consisting of the query for updating the foreign keys in a one-to-many relationship.

Parameters:
rel the com.clarionmedia.infinitum.orm.relationship.OneToManyRelationship for this relationship query
model the model containing the relationship
relatedKeys the java.util.List containing the IDs of entities which are no longer related
Returns:
String containing the SQL query
			List<SerializablerelatedKeys);

Generates a SQL statement for updating the foreign key in a one-to-one relationship.

Parameters:
relationship the com.clarionmedia.infinitum.orm.relationship.OneToOneRelationship for this relationship query
model the model containing the foreign key to update
related the related entity
Returns:
SQL update query
			OneToOneRelationship relationshipObject modelObject related);

Generates an SQL query java.lang.String for deleting relationships from a many-to-many table.

Parameters:
obj owner of the relationship to be deleted
rel the relationship type
Returns:
SQL query
Generates an SQL query java.lang.String for updating a model relationship.

Parameters:
model the model to update
related the related model
column the foreign key column
Returns:
SQL query
	String createUpdateQuery(Object modelObject relatedString column);
New to GrepCode? Check out our FAQ X