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

The following examples show how to use org.springframework.data.jpa.repository.support.JpaRepositoryFactory. These examples are extracted from open source projects. 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 Project: txle   Source File: TxleJpaRepositoryProxyFactory.java    License: 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 Project: tomee   Source File: SpringDataProxy.java    License: 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 Project: tomee   Source File: SpringDataProxy.java    License: 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 Project: ariADDna   Source File: AppConfiguration.java    License: 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 Project: spring-data-examples   Source File: BasicFactorySetup.java    License: 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);

}