jpa use id name in repositories

This commit is contained in:
Niclas Thobaben 2021-09-21 14:46:21 +02:00
parent b8865ecabb
commit 0f8b3699b0
2 changed files with 4 additions and 1 deletions

View file

@ -85,6 +85,8 @@ module.exports = {
repo.pkeyPascalCase = utils.pascalcase(repo.pkey)
repo.pkey_type = model.fields.find(field => field.isPkey).type
repo.findById = repo.pkey != 'id'
repo.name = `${utils.pascalcase(model.name)}Repository`
repo.package = `${namespace}.${suffix}`;
repo.dir = model.package.replace(/\./g, '/')

View file

@ -27,8 +27,9 @@ import java.util.Optional;
public interface {{record_type}}Repository extends JpaRepository<{{record_type}}, {{pkey_type.name}}> {
List<{{record_type}}> findAllBy{{pkeyPascalCase}}In(List<{{pkey_type.name}}> ids);
{{#findById}}
{{record_type}} findBy{{pkeyPascalCase}}(@NonNull {{pkey_type.name}} {{pkey}});
{{/findById}}
{{#indexes}}
List<{{record_type}}> findAllBy{{namePascalCase}}(@NonNull {{type.name}} {{name}});