Documentation for the "fieldFinders" JSON key.

Field finders are a simple way to generate singular finders that act on one or more fields. For field finders that query multiple fields, the fields should be separated by a comma ','.

The key fieldFinders is a JSON Array of JSON Objects on the table JSON object, for example:

"tables": [
	{
		"fields": [
			...
		],
		"fieldFinders": [
			...
		]
	}
]

Adding the following fieldFinders JSON array of JSON Objects:

"fieldFinders": [
	{ "nm_username": "unique" },
	{ "txt_address_email": "unique" },
	{ "num_age": "multiple" },
	{ "fl_is_alive,num_age": "multiple" }
]

The name of the finder will be findBy<CamelCaseFieldName(s)>

This will automatically generate four finders:

  1. The first finder is findByNmUsername. which will return a unique User object that has one parameter passed into the method, namely nmUsername.
  2. The second finder is findByTxtAddressEmail. which will return a unique User object that has one parameter passed into the method, namely txtAddressEmail.
  3. The third finder is findByNumAge which will return an ArrayList<User> that has all of the users with a specific age.
  4. The fourth and final finder is findByFlIsAliveNumAge which will return an ArrayList<User> that has all two parameters passed into it, namely flIsAlive and findByNumAge.

The alternate way to define the above finders is as follows (which would generate identical code):

"finders": [
	{
		"name": "findByNmUsername",
		"whereClause": "where nm_username = ?",
		"whereFields": [
			"nm_username"
		],
		"unique": true
	},
	{
		"name": "findByTxtAddressEmail",
		"whereClause": "where txt_address_email = ?",
		"whereFields": [
			"txt_address_email"
		],
		"unique": true
	},
	{
		"name": "findByNumAge",
		"whereClause": "where num_age = ?",
		"whereFields": [
			"num_age"
		],
		"unique": false
	},
	{
		"name": "findByFlIsAliveNumAge",
		"whereClause": "where fl_is_alive = ? and num_age = ?",
		"whereFields": [
			"fl_is_alive",
			"num_age"
		],
		"unique": false
	},
]

Which as you can see is a lot more work, more prone to error and un-necessary for something that can be automatically generated.