org.springframework.data.jpa.repository.support.JpaRepositoryFactory Java Examples

The following examples show how to use org.springframework.data.jpa.repository.support.JpaRepositoryFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TxleJpaRepositoryProxyFactory.java    From txle with Apache License 2.0 5 votes vote down vote up
protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) {
    try {
        JpaRepositoryFactory jpaFac = new JpaRepositoryFactory(entityManager);
        jpaFac.addRepositoryProxyPostProcessor((proxyFactory, repositoryInformation) -> proxyFactory.addAdvice((MethodInterceptor) methodInvocation -> txleJpaRepositoryInterceptor.doFilter(methodInvocation)));
        return jpaFac;
    } catch (Exception e) {
        return super.createRepositoryFactory(entityManager);
    }
}
 
Example #2
Source File: SpringDataProxy.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (repository.get() == null) {
        synchronized (this) {
            if (repository.get() == null) {
                repository.set(new JpaRepositoryFactory(em).getRepository(implementingInterfaceClass));
            }
        }
    }
    return method.invoke(repository.get(), args);
}
 
Example #3
Source File: SpringDataProxy.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (repository.get() == null) {
        synchronized (this) {
            if (repository.get() == null) {
                repository.set(new JpaRepositoryFactory(em).getRepository(implementingInterfaceClass));
            }
        }
    }
    return method.invoke(repository.get(), args);
}
 
Example #4
Source File: AppConfiguration.java    From ariADDna with Apache License 2.0 4 votes vote down vote up
@Bean
public RepositoryFactorySupport repositoryFactorySupport() {
    LOGGER.info("In bean repositoryFactorySupport() entity manager is : {}", em.toString());
    return new JpaRepositoryFactory(em);
}
 
Example #5
Source File: BasicFactorySetup.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a {@link SimpleUserRepository} instance.
 *
 * @throws Exception
 */
@Before
public void setUp() {

	em = factory.createEntityManager();

	userRepository = new JpaRepositoryFactory(em).getRepository(SimpleUserRepository.class);

	em.getTransaction().begin();

	user = new User();
	user.setUsername("username");
	user.setFirstname("firstname");
	user.setLastname("lastname");

	user = userRepository.save(user);

}