Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2004 - 2011 Brian McCallister
  *
  * 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.skife.jdbi.v2.sqlobject;
This duplicates the API on org.skife.jdbi.v2.DBI and org.skife.jdbi.v2.Handle for creating sql objects. While it is fine to use these methods to create sql objects, there is no real difference between them and the oones on DBI and Handle.
public class SqlObjectBuilder
{

    
Create a a sql object of the specified type bound to this handle. Any state changes to the handle, or the sql object, such as transaction status, closing it, etc, will apply to both the object and the handle.

Parameters:
handle the Handle instance to attach ths sql object to
sqlObjectType the type of sql object to create
Returns:
the new sql object bound to this handle
    public static <T> T attach(Handle handleClass<T> sqlObjectType)
    {
        return SqlObject.buildSqlObject(sqlObjectTypenew ConstantHandleDing(handle));
    }

    
Open a handle and attach a new sql object of the specified type to that handle. Be sure to close the sql object (via a close() method, or calling org.skife.jdbi.v2.IDBI.close(java.lang.Object)

Parameters:
dbi the dbi to be used for opening the underlying handle
sqlObjectType an interface with annotations declaring desired behavior
Returns:
a new sql object of the specified type, with a dedicated handle
    public static <T> T open(IDBI dbiClass<T> sqlObjectType)
    {
        return SqlObject.buildSqlObject(sqlObjectTypenew ConstantHandleDing(dbi.open()));
    }

    
Create a new sql object which will obtain and release connections from this dbi instance, as it needs to, and can, respectively. You should not explicitely close this sql object

Parameters:
dbi the DBI instance to be used for obtaining connections when they are required
sqlObjectType an interface with annotations declaring desired behavior
Returns:
a new sql object of the specified type, with a dedicated handle
    public static <T> T onDemand(final IDBI dbifinal Class<T> sqlObjectType)
    {
        return SqlObject.buildSqlObject(sqlObjectTypenew OnDemandHandleDing(dbi));
    }

    
Used to close a sql object which lacks a close() method.

Parameters:
sqlObject the sql object to close
    public static void close(Object sqlObject)
    {
        SqlObject.close(sqlObject);
    }
New to GrepCode? Check out our FAQ X