What do you need...
Whatever you need to do on the database, there is something for you
- Find something... (or a subset of things)
- Count something... (or a subset of things - i.e. return a number from a query)
- Question something... (i.e. return a boolean yes or no from a query)
- Delete something... (or a subset of things)
- Update something... (or a subset of things)
I need to find something...
- Find everything...
- There is a
findAll
method on everyFinder
- Find by primary key...
- There is a
findByPrimaryKey
method on everyFinder
- Find all rows that match a query
- In the
.json
file you can use afinder
, or for a short-cut method afieldFinder
, example:
"fieldFinders": [
{ "field_one": "multiple" },
{ "field_one,field_two": "unique" }
]
multiple
multiple
- This designation tells h2zero that one or more rows will be returned
The first field finder will generate a where clause with the parameter: field_one
, (e.g. select * from table where field_one = ?
)
The generated code will create a method that returns a List<Model>
with a signature that would be of the form: public List<Model> findByFieldOne(<Type> fieldOne);
unique
unique
(you may also usesingle
)- This designation tells h2zero that only one row will be returned
the second will generate a where clause with two parameters, namely: field_one
and field_two
(e.g. select * from table where field_one = ? and field_two = ?
)
The generated code will create a method that returns a Model
with a signature that would be of the form: public Model findByFieldOneFieldTwo(<Type> fieldOne, <Type> fieldTwo);
- Find a sub-set of fields
- In the
.json
file you can use aselectClauseFinder
which will return aselectClauseBean
, this will only return a sub-set of the fields in a table, encapsulated in a Bean.
I need to count something...
Remember: counters always return a single integer
value...
- Count all...
- There is a
countAll
method on everyCount
- Count all rows that match a query
- In the
.json
file you can use acounter
with awhereClause
I need to question something...
Remember: questions always return a single boolean
value...
- Boolean question...
- In the
.json
file you can use anquestion
I need to delete something...
- Delete all...
- There is a
deleteAll
method on everyDeleter
- Delete by primary key...
- There is a
deleteByPrimaryKey
method on everyDeleter
- Delete all rows that match a query
- In the
.json
file you can use adeleter
with awhereClause
I need to update something...
- Update all rows that match a query
- In the
.json
file you can use anupdater
with awhereClause