@RepositoryDefinition(domainClass = Hello.class, idClass = Long.class) public interface HelloRepoAnnotation { Hello save(Hello hello); Optional<Hello> findById(Long id); }
@Override protected RepositoryMetadata resolveFromInterface(Class<?> repositoryInterface) { final RepositoryDefinition definition = repositoryInterface.getAnnotation(RepositoryDefinition.class); if (definition == null) { throw new RepositoryDefinitionException(repositoryInterface, "Expected the repository to be annotated with @RepositoryDefinition"); } final Class<?> entityType = definition.domainClass(); final Class<? extends Serializable> idType = definition.idClass(); String idProperty = resolveIdProperty(entityType, idType); return new ImmutableRepositoryMetadata(idType, entityType, repositoryInterface, idProperty); }
private Class<?> resolveDomainType(Class<?> repositoryInterface) { RepositoryDefinition annotation = repositoryInterface.getAnnotation(RepositoryDefinition.class); if (annotation == null || annotation.domainClass() == null) { throw new IllegalArgumentException(String.format("Could not resolve domain type of %s!", repositoryInterface)); } return annotation.domainClass(); } }
public Class<? extends Serializable> getIdType() { RepositoryDefinition annotation = repositoryInterface.getAnnotation(RepositoryDefinition.class); return annotation == null ? null : annotation.idClass(); }
@Override protected RepositoryMetadata resolveFromInterface(Class<?> repositoryInterface) { final RepositoryDefinition definition = repositoryInterface.getAnnotation(RepositoryDefinition.class); if (definition == null) { throw new RepositoryDefinitionException(repositoryInterface, "Expected the repository to be annotated with @RepositoryDefinition"); } final Class<?> entityType = definition.domainClass(); final Class<? extends Serializable> idType = definition.idClass(); String idProperty = resolveIdProperty(entityType, idType); return new ImmutableRepositoryMetadata(idType, entityType, repositoryInterface, idProperty); }
public Class<?> getDomainType() { RepositoryDefinition annotation = repositoryInterface.getAnnotation(RepositoryDefinition.class); return annotation == null ? null : annotation.domainClass(); }
private Class<?> resolveIdType(Class<?> repositoryInterface) { RepositoryDefinition annotation = repositoryInterface.getAnnotation(RepositoryDefinition.class); if (annotation == null || annotation.idClass() == null) { throw new IllegalArgumentException(String.format("Could not resolve id type of %s!", repositoryInterface)); } return annotation.idClass(); }
@RepositoryDefinition(domainClass = Hello.class, idClass = Long.class) public interface HelloRepoAnnotation { Hello save(Hello hello); Optional<Hello> findById(Long id); }
@RepositoryDefinition(domainClass = TvSeries.class, idClass = Integer.class) public interface TvSeriesDao extends JpaRepository<TvSeries,Integer>{ @Modifying @Query(value="update tv_series set status=-1, reason=?2 where id=?1", nativeQuery = true) public int logicDelete(int id, String reason); }
@RepositoryDefinition(domainClass = TvCharacter.class, idClass = Integer.class) public interface TvCharacterDao extends JpaRepository<TvCharacter, Integer>{ public List<TvCharacter> getAllByTvSeriesId(int tvSeriesId); }