com.aiyc.server.standalone.db.homes
类 EntityHome<T extends IEntity<Integer>>

java.lang.Object
  继承者 com.aiyc.server.standalone.db.homes.EntityHome<T>
所有已实现的接口:
IArea, IEntityHome<T,Integer>
直接已知子类:
BluetoothReadingHome, FingerprintHome, GSMReadingHome, LocationHome, MapHome, MeasurementHome, ReadingInMeasurementHome, WiFiReadingHome

public abstract class EntityHome<T extends IEntity<Integer>>
extends Object
implements IEntityHome<T,Integer>, IArea


字段摘要
protected  String area
           
protected  com.waspring.wasdbtools.DatabaseConnection db
           
protected  String deleteSQL
           
protected  String insertSQL
           
protected  Logger log
           
protected  int primaryKeyId
           
protected  String selectSQL
           
protected  String TableColNames
           
protected  String updateSQL
           
 
构造方法摘要
EntityHome()
           
 
方法摘要
 List<T> add(List<T> list)
          Add a list of entities
 T add(T e)
          Add an entity to the database.
 int executeInsertUpdate(Vector<PreparedStatement> vps, T e)
           
protected  int fillInStatement(PreparedStatement ps, Object[] values, int[] sqlTypes)
           
protected  int fillInStatement(PreparedStatement ps, Object[] values, int[] sqlTypes, int fromIndex)
          Fills values into the PreparedStatement starting at fromIndex
protected  int fillInStatement(PreparedStatement ps, T e)
           
protected abstract  int fillInStatement(PreparedStatement ps, T e, int fromIndex)
          Fills entity values into the PreparedStatement starting at fromIndex
 List<T> get(List<T> list)
          Get a List of entities
protected  List<T> get(String constraint)
          Gets entities from database matching a constraint
 T get(T e)
          Get an entity
 List<T> getAll()
          Get all entities
 String getArea()
           
 T getById(Integer id)
          Get an entity by it's primary key
 List<T> getById(List<Integer> ids)
          Get a List of entities by their primary keys
 T getByName(String name)
           
protected  String getDeleteSQL()
           
protected  ResultSet getGeneratedKey(PreparedStatement ps)
          Helper function to get generated key Does consider different methods of retrieving the generated keys depending on the database
protected  String getInsertSQL()
           
protected  String getOrder()
           
protected  PreparedStatement getPreparedStatement(String sql)
          Helper function to get a prepared statement.
protected  int getPrimaryKeyId()
           
protected  String getSelectSQL()
           
protected  String getTableColNames()
           
protected abstract  String[] getTableCols()
           
protected abstract  String getTableIdCol()
           
protected abstract  String getTableName()
           
protected  String getUpdateSQL()
           
protected static String implode(Object[] obj)
           
protected  T parseResultRow(ResultSet rs)
           
abstract  T parseResultRow(ResultSet rs, int fromIndex)
          This function restores an entity from a database row
 boolean remove(List<T> list)
          Removes a List of entities
protected  boolean remove(String constraint)
          Removes entities from database matching a constraint
 boolean remove(T e)
          Removes an entity
 boolean removeAll()
          Removes all entities from database
 void setArea(String area)
           
 boolean update(List<T> list)
          Updates a List of entities
 boolean update(T e)
          Updates an entity
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

area

protected String area

primaryKeyId

protected int primaryKeyId

db

protected com.waspring.wasdbtools.DatabaseConnection db

log

protected Logger log

TableColNames

protected String TableColNames

insertSQL

protected String insertSQL

updateSQL

protected String updateSQL

selectSQL

protected String selectSQL

deleteSQL

protected String deleteSQL
构造方法详细信息

EntityHome

public EntityHome()
方法详细信息

getArea

public String getArea()
指定者:
接口 IArea 中的 getArea

setArea

public void setArea(String area)
指定者:
接口 IArea 中的 setArea

getTableName

protected abstract String getTableName()
返回:
Table name of entity

getTableColNames

protected String getTableColNames()
返回:
columns names of entity for a query

getPrimaryKeyId

protected int getPrimaryKeyId()
返回:
next primary key for the entry

getInsertSQL

protected String getInsertSQL()
返回:
prepared INSERT sql string

getUpdateSQL

protected String getUpdateSQL()
返回:
prepared UPDATE sql string

getSelectSQL

protected String getSelectSQL()
返回:
prepared SELECT sql string

getOrder

protected String getOrder()
返回:
SQL ORDER BY string

getDeleteSQL

protected String getDeleteSQL()
返回:
prepared DELETE sql string

getTableIdCol

protected abstract String getTableIdCol()
返回:
Primary key column name

getTableCols

protected abstract String[] getTableCols()
返回:
All table columns excluding the primary key column

parseResultRow

protected T parseResultRow(ResultSet rs)
                                             throws SQLException
参数:
rs - ResultSet
返回:
Restored entity from database row
抛出:
SQLException
另请参见:
parseResultRow(ResultSet, int)

parseResultRow

public abstract T parseResultRow(ResultSet rs,
                                 int fromIndex)
                                                   throws SQLException
This function restores an entity from a database row

参数:
rs - ResultSet
fromIndex - index from where the parsing starts
返回:
Restored entity from database row
抛出:
SQLException

fillInStatement

protected int fillInStatement(PreparedStatement ps,
                              Object[] values,
                              int[] sqlTypes)
                       throws SQLException
参数:
ps - PreparedStatement
values - entity values
sqlTypes - corresponding SQL Types for values
返回:
number of filled in values
抛出:
SQLException
另请参见:
fillInStatement(PreparedStatement, Object[], int[], int)

fillInStatement

protected int fillInStatement(PreparedStatement ps,
                              Object[] values,
                              int[] sqlTypes,
                              int fromIndex)
                       throws SQLException
Fills values into the PreparedStatement starting at fromIndex

参数:
ps - PreparedStatement
values - entity values
sqlTypes - corresponding SQL Types for values
fromIndex - index from where the filling in starts
返回:
number of filled in values
抛出:
SQLException

fillInStatement

protected int fillInStatement(PreparedStatement ps,
                              T e)
                       throws SQLException
参数:
ps - PreparedStatement
e - Entity
返回:
number of filled in values
抛出:
SQLException
另请参见:
fillInStatement(PreparedStatement, IEntity, int)

fillInStatement

protected abstract int fillInStatement(PreparedStatement ps,
                                       T e,
                                       int fromIndex)
                                throws SQLException
Fills entity values into the PreparedStatement starting at fromIndex

参数:
ps - PreparedStatement
e - Entity
返回:
number of filled in values
抛出:
SQLException

executeInsertUpdate

public int executeInsertUpdate(Vector<PreparedStatement> vps,
                               T e)
                        throws SQLException
参数:
vps - Vector<PreparedStatement>
e - entity
返回:
primary key for the new entry
抛出:
SQLException

add

public T add(T e)
Add an entity to the database.

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 add
参数:
e - Entity
返回:
Entity with its generated primary key

add

public List<T> add(List<T> list)
Add a list of entities

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 add
参数:
list - List of entities
返回:
List of entities with their generated primary keys

get

protected List<T> get(String constraint)
Gets entities from database matching a constraint

参数:
constraint - SQL WHERE constraint
返回:
List of entities matching the constraint

get

public T get(T e)
Get an entity

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 get
参数:
e - Entity
返回:
Entity with all fields filled from database

getById

public T getById(Integer id)
Get an entity by it's primary key

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 getById
参数:
id - Primary Key
返回:
Entity

getByName

public T getByName(String name)

get

public List<T> get(List<T> list)
Get a List of entities

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 get
参数:
list - List of primary keys
返回:
List of entities

getById

public List<T> getById(List<Integer> ids)
Get a List of entities by their primary keys

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 getById
参数:
ids - List of primary keys
返回:
List of entities

getAll

public List<T> getAll()
Get all entities

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 getAll
返回:
List of all entities

remove

protected boolean remove(String constraint)
Removes entities from database matching a constraint

参数:
constraint - SQL WHERE constraint
返回:
True if successful

remove

public boolean remove(T e)
Removes an entity

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 remove
参数:
e - Entity
返回:
True if successful

remove

public boolean remove(List<T> list)
Removes a List of entities

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 remove
参数:
list - List of entities
返回:
True if removal of all entities was successful

removeAll

public boolean removeAll()
Removes all entities from database

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 removeAll
返回:
True if removal was successful

update

public boolean update(T e)
Updates an entity

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 update
参数:
e - Entity
返回:
True if successful

update

public boolean update(List<T> list)
Updates a List of entities

指定者:
接口 IEntityHome<T extends IEntity<Integer>,Integer> 中的 update
参数:
list - List of entities to be updated
返回:
true if all entities were updated successfully

getPreparedStatement

protected PreparedStatement getPreparedStatement(String sql)
                                          throws SQLException
Helper function to get a prepared statement. Does consider different methods of retrieving the generated keys depending on the database

参数:
sql - SQL command
返回:
PreparedStatement
抛出:
SQLException

getGeneratedKey

protected ResultSet getGeneratedKey(PreparedStatement ps)
                             throws SQLException
Helper function to get generated key Does consider different methods of retrieving the generated keys depending on the database

参数:
ps - PreparedStatement
返回:
ResultSet with generated key
抛出:
SQLException

implode

protected static String implode(Object[] obj)
参数:
obj - Objects to be imploded
返回:
String with each object separated by a colon


Copyright © 2017. All Rights Reserved.