Class AbstractPersistenceProcessor
java.lang.Object
org.eclipse.dirigible.database.persistence.processors.AbstractPersistenceProcessor
- All Implemented Interfaces:
IPersistenceProcessor
- Direct Known Subclasses:
PersistenceCreateIdentityProcessor,PersistenceCreateSequenceProcessor,PersistenceCreateTableProcessor,PersistenceDeleteProcessor,PersistenceDropSequenceProcessor,PersistenceDropTableProcessor,PersistenceExecuteProcessor,PersistenceInsertProcessor,PersistenceNextValueIdentityProcessor,PersistenceNextValueSequenceProcessor,PersistenceQueryProcessor,PersistenceUpdateProcessor
public abstract class AbstractPersistenceProcessor extends Object implements IPersistenceProcessor
The Abstract Persistence Processor.
-
Constructor Summary
Constructors Modifier Constructor Description AbstractPersistenceProcessor()Instantiates a new abstract persistence processor.protectedAbstractPersistenceProcessor(IEntityManagerInterceptor entityManagerInterceptor)Instantiates a new abstract persistence processor. -
Method Summary
Modifier and Type Method Description protected voidclosePreparedStatement(PreparedStatement preparedStatement)Close prepared statement.protected abstract StringgenerateScript(Connection connection, PersistenceTableModel tableModel)Generate script.IEntityManagerInterceptorgetEntityManagerInterceptor()Gets the entity manager interceptor.StringgetPrimaryKey(PersistenceTableModel tableModel)Gets the primary key.protected PersistenceTableColumnModelgetPrimaryKeyModel(PersistenceTableModel tableModel)Gets the primary key model.protected ObjectgetValueFromPojo(Object pojo, PersistenceTableColumnModel columnModel)Gets the value from pojo.protected PreparedStatementopenPreparedStatement(Connection connection, String sql)Open prepared statement.voidsetEntityManagerInterceptor(IEntityManagerInterceptor entityManagerInterceptor)Sets the entity manager interceptor.protected voidsetValue(PreparedStatement preparedStatement, int i, Object value)Sets the value.protected voidsetValue(PreparedStatement preparedStatement, int i, String dataType, Object value)Sets the value.protected voidsetValuePrimaryKey(PersistenceTableModel tableModel, Object id, PreparedStatement preparedStatement)Sets the value primary key.protected voidsetValuesFromPojo(PersistenceTableModel tableModel, Object pojo, PreparedStatement preparedStatement)Sets the values from pojo.protected voidsetValueToPojo(Object pojo, Object value, PersistenceTableColumnModel columnModel)Sets the value to pojo.protected voidsetValueToPojo(Object pojo, ResultSet resultSet, PersistenceTableColumnModel columnModel)Sets the value to pojo.protected booleanshouldSetColumnValue(PersistenceTableColumnModel columnModel)Should set column value.
-
Constructor Details
-
AbstractPersistenceProcessor
public AbstractPersistenceProcessor()Instantiates a new abstract persistence processor. -
AbstractPersistenceProcessor
Instantiates a new abstract persistence processor.- Parameters:
entityManagerInterceptor- the entity manager interceptor
-
-
Method Details
-
generateScript
Generate script.- Parameters:
connection- the connectiontableModel- the table model- Returns:
- the string
-
setValuesFromPojo
protected void setValuesFromPojo(PersistenceTableModel tableModel, Object pojo, PreparedStatement preparedStatement) throws SQLException, NoSuchFieldException, IllegalAccessExceptionSets the values from pojo.- Parameters:
tableModel- the table modelpojo- the pojopreparedStatement- the prepared statement- Throws:
SQLException- the SQL exceptionNoSuchFieldException- the no such field exceptionIllegalAccessException- the illegal access exception
-
shouldSetColumnValue
Should set column value.- Parameters:
columnModel- the column model- Returns:
- true, if successful
-
setValuePrimaryKey
protected void setValuePrimaryKey(PersistenceTableModel tableModel, Object id, PreparedStatement preparedStatement) throws SQLException, NoSuchFieldException, IllegalAccessExceptionSets the value primary key.- Parameters:
tableModel- the table modelid- the idpreparedStatement- the prepared statement- Throws:
SQLException- the SQL exceptionNoSuchFieldException- the no such field exceptionIllegalAccessException- the illegal access exception
-
setValue
protected void setValue(PreparedStatement preparedStatement, int i, Object value) throws SQLExceptionSets the value.- Parameters:
preparedStatement- the prepared statementi- the ivalue- the value- Throws:
SQLException- the SQL exception
-
setValue
protected void setValue(PreparedStatement preparedStatement, int i, String dataType, Object value) throws SQLExceptionSets the value.- Parameters:
preparedStatement- the prepared statementi- the idataType- the data typevalue- the value- Throws:
SQLException- the SQL exception
-
setValueToPojo
protected void setValueToPojo(Object pojo, ResultSet resultSet, PersistenceTableColumnModel columnModel) throws NoSuchFieldException, SQLException, IllegalAccessException, IOExceptionSets the value to pojo.- Parameters:
pojo- the pojoresultSet- the result setcolumnModel- the column model- Throws:
NoSuchFieldException- the no such field exceptionSQLException- the SQL exceptionIllegalAccessException- the illegal access exceptionIOException
-
setValueToPojo
protected void setValueToPojo(Object pojo, Object value, PersistenceTableColumnModel columnModel) throws NoSuchFieldException, SQLException, IllegalAccessException, IOExceptionSets the value to pojo.- Parameters:
pojo- the pojovalue- the valuecolumnModel- the column model- Throws:
NoSuchFieldException- the no such field exceptionSQLException- the SQL exceptionIllegalAccessException- the illegal access exceptionIOException
-
getValueFromPojo
protected Object getValueFromPojo(Object pojo, PersistenceTableColumnModel columnModel) throws NoSuchFieldException, SQLException, IllegalAccessExceptionGets the value from pojo.- Parameters:
pojo- the pojocolumnModel- the column model- Returns:
- the value from pojo
- Throws:
NoSuchFieldException- the no such field exceptionSQLException- the SQL exceptionIllegalAccessException- the illegal access exception
-
openPreparedStatement
protected PreparedStatement openPreparedStatement(Connection connection, String sql) throws SQLExceptionOpen prepared statement.- Parameters:
connection- the connectionsql- the sql- Returns:
- the prepared statement
- Throws:
SQLException- the SQL exception
-
closePreparedStatement
Close prepared statement.- Parameters:
preparedStatement- the prepared statement
-
getPrimaryKey
Gets the primary key.- Parameters:
tableModel- the table model- Returns:
- the primary key
-
getPrimaryKeyModel
Gets the primary key model.- Parameters:
tableModel- the table model- Returns:
- the primary key model
-
getEntityManagerInterceptor
Gets the entity manager interceptor.- Returns:
- the entity manager interceptor
-
setEntityManagerInterceptor
Sets the entity manager interceptor.- Parameters:
entityManagerInterceptor- the new entity manager interceptor
-