Skip to content

Commit

Permalink
Added to DinaService
Browse files Browse the repository at this point in the history
  • Loading branch information
cgendreau committed Nov 6, 2023
1 parent 5137e6f commit 1431124
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,18 @@ public <T> Long getResourceCount(
(criteriaBuilder, root, em) -> predicateSupplier.apply(criteriaBuilder, root));
}

/**
* Find an entity by its NaturalId. The method assumes that the naturalId is unique.
*
* @param naturalId - natural id of entity
* @param entityClass - class of entity
* @return the matched entity
*/

@Override
public <T> T findOne(Object naturalId, Class<T> entityClass) {
return baseDAO.findOneByNaturalId(naturalId, entityClass);
}

@Override
public <T> T findOne(Object naturalId, Class<T> entityClass, Set<String> relationships) {
Map<String, Object> hints = relationships.isEmpty() ? null : relationshipPathToLoadHints(entityClass, relationships);
return baseDAO.findOneByNaturalId(naturalId, entityClass, hints);
}

/**
* Find an entity by its database id.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,24 @@ public interface DinaService<E extends DinaEntity> {
void delete(E entity);

/**
* Find an entity by it's NaturalId. The method assumes that the naturalId is unique.
* Find an entity by its NaturalId. The method assumes that the naturalId is unique.
*
* @param naturalId - id of entity
* @param entityClass - class of entity
* @return the matched entity
* @return the matched entity or null if not found
*/
<T> T findOne(Object naturalId, Class<T> entityClass);

/**
* Find an entity by its NaturalId. The method assumes that the naturalId is unique.
* The relationships set can be used to force lazy loaded relationships to be loaded.
* @param naturalId
* @param entityClass
* @param relationships relationships to load or an empty set, not null.
* @return the matched entity or null if not found
*/
<T> T findOne(Object naturalId, Class<T> entityClass, Set<String> relationships);

/**
* Returns a reference to an entity that should exist without actually loading it. Useful to set
* relationships without loading the entity instead of findOne.
Expand Down

0 comments on commit 1431124

Please sign in to comment.