Class SQLInsert
java.lang.Object
ece.ing3.java.projet.database.sql.queries.SQLInsert
- All Implemented Interfaces:
SQLRequest
SQL insert helper.
Provides a convenient way to build insert SQL queries, reactive-style, for a provided model class.
- Author:
- Virgile, Nicolas, Louis-Félix
-
Constructor Details
-
SQLInsert
Creates a new helper for a model class.- Parameters:
modelClass
- Model class
-
-
Method Details
-
getModelClass
- Specified by:
getModelClass
in interfaceSQLRequest
-
add
Add a new value to the request.- Parameters:
column
- Column to targetvalue
- Value to add- Returns:
- This SQL insert helper
-
insert
Inserts the built row in the database.- Returns:
- Either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Throws:
IllegalArgumentException
- No values where addedDatabaseException
- Database error
-
toString
Generate the SQL query for this insert helper.- Specified by:
toString
in interfaceSQLRequest
- Overrides:
toString
in classObject
- Returns:
- Generated SQL query
- Throws:
IllegalArgumentException
- No values where added
-
getParameters
Description copied from interface:SQLRequest
Gets all the request's parameters- Specified by:
getParameters
in interfaceSQLRequest
- Returns:
- Request parameters
-