本文整理汇总了Java中org.springframework.data.jpa.repository.support.JpaRepositoryFactory类的典型用法代码示例。如果您正苦于以下问题:Java JpaRepositoryFactory类的具体用法?Java JpaRepositoryFactory怎么用?Java JpaRepositoryFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JpaRepositoryFactory类属于org.springframework.data.jpa.repository.support包,在下文中一共展示了JpaRepositoryFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; //导入依赖的package包/类
/**
* Creates a {@link SimpleUserRepository} instance.
*
* @throws Exception
*/
@Before
public void setUp() {
em = factory.createEntityManager();
projectRepository = new JpaRepositoryFactory(em).getRepository(TMProjectRepository.class);
userRepository = new JpaRepositoryFactory(em).getRepository(TMUserRepository.class);
em.getTransaction().begin();
user = new TMUser("jchaganti", "jch");
user = userRepository.save(user);
project = TMProject.getBuilder(user, "description", "title").build();
project = projectRepository.save(project);
em.getTransaction().commit();
}
示例2: invoke
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; //导入依赖的package包/类
@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);
}
示例3: afterPropertiesSet
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; //导入依赖的package包/类
@Override
public void afterPropertiesSet() {
applicationContext.getAutowireCapableBeanFactory().autowireBean(this);
this.jpaRepositoryFactory = new JpaRepositoryFactory(entityManager);
try {
// Make sure calls to the repository instance are intercepted for annotated transactions
Class transactionalRepositoryProxyPostProcessor = Class.forName("org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor");
final Constructor constructor = transactionalRepositoryProxyPostProcessor.getConstructor(ListableBeanFactory.class, String.class);
final RepositoryProxyPostProcessor repositoryProxyPostProcessor = (RepositoryProxyPostProcessor)
constructor.newInstance(applicationContext.getBeanFactory(), TxUtils.DEFAULT_TRANSACTION_MANAGER);
jpaRepositoryFactory.addRepositoryProxyPostProcessor(repositoryProxyPostProcessor);
} catch (Exception e) {
log.error("Failed to initialize the TransactionalRepositoryProxyPostProcessor class", e);
}
}
示例4: setUp
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; //导入依赖的package包/类
/**
* 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);
}
示例5: repositoryFactorySupport
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; //导入依赖的package包/类
@Bean
public RepositoryFactorySupport repositoryFactorySupport(){
LOGGER.info("In bean repositoryFactorySupport() entity manager is : {}", em.toString());
return new JpaRepositoryFactory(em);
}
示例6: repositoryFactory
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; //导入依赖的package包/类
@Bean
public JpaRepositoryFactory repositoryFactory(EntityManagerFactory emf) {
return new JpaRepositoryFactory(emf.createEntityManager());
}
示例7: addressStorage
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; //导入依赖的package包/类
@Bean
public AddressStorage addressStorage(JpaRepositoryFactory rf) {
return rf.getRepository(AddressStorage.class);
}
示例8: emailStorage
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; //导入依赖的package包/类
@Bean
public EmailStorage emailStorage(JpaRepositoryFactory rf) {
return rf.getRepository(EmailStorage.class);
}
示例9: phoneStorage
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; //导入依赖的package包/类
@Bean
public PhoneStorage phoneStorage(JpaRepositoryFactory rf) {
return rf.getRepository(PhoneStorage.class);
}