I have this simple JPARepository ```interface Pro...
# spring
d
I have this simple JPARepository
Copy code
interface ProductDAO : JpaRepository<ProductDTO, UUID>
That I would like to instantiate manually so I can register it via the beans Kotlin DSL like this:
Copy code
fun beanDeclarations() = beans {
    bean<ProductDAO>()
    bean<ProductRepository> {
        ProductJPARepository(ref())
    }
    bean<ProductApplicationService> {
        ProductApplicationServiceImpl(ref())
    }
}
Could find anything in the interweb … @sdeleuze
k
I would check something like
JpaRepositoryFactory(entityManager).getRepository(ProductDAO.class)
n
you don’t need to instantiate it if you need it in one of your bean, just write
ref()
as it’s already part of the context
👍 1
d
Thx for the answers…is it necessary to tag the repository
ProductDAO
with
@Repository
? And is there a way to do it without the annotation if so?
l
if don't strictly have the need of staying stick to JPA, I would suggest to have a look at Jetbrains Exposed as a substitute. It takes no more then one day to have a complete overlook. It makes writing repositories really straightforward and you don't have the cognitive overhead of conventions over configuration