Android Open Source - ormada Dialect






From Project

Back to project page ormada.

License

The source code is released under:

Copyright (c) 2012 Jesse Rosalia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Sof...

If you think the Android project ormada listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.ormada.dialect;
/*from   ww  w .ja v a2s .c  om*/
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.ormada.ORMDataSource;

public interface Dialect<V extends ValueSet> {

  void close() throws SQLException;
    
  /**
   * Get the column type definition for the type class passed in
   * 
   * Implementations must handle both primitives and capital letter types according to one specific rule:
   *     Primitives are not nullable, all other types are.
   * 
   * The core framework expects and relies on this convention.
   * 
   * @param typeClass
   * @return
   */
  String getColumnType(Class<?> typeClass);

  /**
   * Get the column type definition for the primary key.
   * 
   * Implementations must provide a definition for a long integer type, as specified in the parameter
   *  (e.g. this must be equivalent to getColumnType(Long.class) with all required primary key modifiers).
   * 
   * @return
   */
    String getPrimaryKeyColumnType();

    /**
     * Prepare a value set to be populated with data for an entity.
     * 
     * Implementations may choose how to manage creation/reuse of these objects.
     * 
     * @return
     */
  ValueSet prepareValueSet();
  
  /**
   * Open a connection to the underlying data source.
   * 
   * @param orm The ORMDataSource object that is managing the object relationships.  This is likely used
   * during the open process to create and upgrade tables.
   * @throws SQLException 
   */
  void open(ORMDataSource orm) throws SQLException;

  /**
   * Test if the underlying data source is open.
   * 
   * @return
   */
    boolean isOpen();

    /**
     * Execute a SQL statement against the underlying data source.  It is assumed that
     * this will not return a value (e.g. no queries or inserts).
     * 
     * @param stmt
     * @throws SQLException
     */
  void execSQL(String stmt) throws SQLException;

  /**
   * Delete all elements that match the where clause and parameters from the specified table.
   * 
   * @param table
   * @param whereClause
   * @param whereParams
   * @throws SQLException
   */
  void delete(String table, String whereClause, String[] whereParams) throws SQLException;

  /**
   * Save multiple entities to the database.  This performs a save operation (insert or update)
   * across multiple objects across multiple tables in an efficient way.
   * 
   * @param valueMap A map of table names to list of ValueSet objects to save
   * @return A map of table to list of ids for the objects saved to that table.  This entry will have an id
   * regardless of whether the row was inserted or updated (for correspondence with the valueMap)
   */
    Map<String, List<Long>> bulkSave(Map<String, List<V>> valueMap);

    /**
     * Count the entries in the specified table that conform to the specified where clause.
     * 
     * @param table
     * @param whereClause
     * @param whereParams
     * @return
     * @throws SQLException
     */
    long count(String table, String whereClause, String[] whereParams) throws SQLException;

    /**
   * Raw insert into the database.  This will insert the values set in the ValueSet
   * into a new row in the specified table.
   * 
   * @param table
   * @param values
   * @return
   * @throws SQLException
   */
  long insert(String table, V values) throws SQLException;

    /**
     * Save an entity to the database.  This method uses the id set inside the ValueSet
     * to determine whether to insert a new row or update an existing row for the
     * given entity
     * 
     * @param table
     * @param values
     * @return
     */
    long save(String table, V values) throws SQLException;

    /**
     * Raw update of a row or rows in the database.  This will update the values set in the ValueSet
     * in rows that correspond with the where clause/params.
     * 
     * @param table
     * @param values
     * @return
     * @throws SQLException
     */
  void update(String table, V values, String whereClause,  String[] whereParams) throws SQLException;

  /**
   * Query for the specified fields, with the specified parameters, against the table and return
   * a cursor to the results.
   * 
   * @param table
   * @param fields
   * @param selectionClause
   * @param selectionArgs
   * @param groupBy
   * @param having
   * @param orderBy
   * @return
   * @throws SQLException
   */
  QueryCursor query(String table, String[] fields, String selectionClause,
      String[] selectionArgs, String groupBy, String having, String orderBy) throws SQLException;

    /**
     * Query for the specified fields, with the specified parameters, against the table and return
     * a cursor to the results.
     * 
     * @param table
     * @param fields
     * @param selectionClause
     * @param selectionArgs
     * @param groupBy
     * @param having
     * @param orderBy
     * @return
     * @throws SQLException
     */
  QueryCursor query(String table, String[] fields, String selectionClause,
      String[] selectionArgs, String groupBy, String having, String orderBy, String limit) throws SQLException;

}




Java Source Code List

org.andrormeda.dialect.SQLiteCursor.java
org.andrormeda.dialect.SQLiteDialect.java
org.andrormeda.dialect.SQLiteValueSet.java
org.andrormeda.example.AppDataSource.java
org.andrormeda.example.ExampleActivity.java
org.andrormeda.example.model.Cat.java
org.andrormeda.example.model.Kitten.java
org.ormada.ORMDataSource.java
org.ormada.annotations.OneToMany.java
org.ormada.annotations.Owner.java
org.ormada.annotations.Reference.java
org.ormada.annotations.Text.java
org.ormada.annotations.Transient.java
org.ormada.dialect.AStandardSQLDialect.java
org.ormada.dialect.DefaultValueSet.java
org.ormada.dialect.Dialect.java
org.ormada.dialect.ForwardOnlyResultSetCursor.java
org.ormada.dialect.FullResultSetCursor.java
org.ormada.dialect.QueryCursor.java
org.ormada.dialect.ValueSet.java
org.ormada.entity.EntityBuilder.java
org.ormada.entity.EntityCache.java
org.ormada.entity.EntityMetaData.java
org.ormada.entity.Entity.java
org.ormada.exception.MixedCollectionException.java
org.ormada.exception.UnableToOpenException.java
org.ormada.exception.UnsavedReferenceException.java
org.ormada.hsql.dialect.HSQLDialect.java
org.ormada.hsql.example.AppDataSource.java
org.ormada.hsql.example.ExampleMain.java
org.ormada.hsql.example.model.Cat.java
org.ormada.hsql.example.model.Kitten.java
org.ormada.model.ORMeta.java
org.ormada.reflect.DefaultReflector.java
org.ormada.reflect.Reflector.java
org.ormada.util.Profiler.java