Java 类org.springframework.data.jpa.repository.support.JpaRepositoryFactory 实例源码

项目:tasquemann    文件:BasicFactorySetup.java   
/**
    * 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();

}
项目:tomee    文件:SpringDataProxy.java   
@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);
}
项目:tomee    文件:SpringDataProxy.java   
@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);
}
项目:parkingfriends    文件:SpringReloader.java   
@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);
    }
}
项目:spring-data-examples    文件:BasicFactorySetup.java   
/**
 * 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);

}
项目:ariADDna    文件:AppConfiguration.java   
@Bean
public RepositoryFactorySupport repositoryFactorySupport(){
    LOGGER.info("In bean repositoryFactorySupport() entity manager is : {}", em.toString());
    return new JpaRepositoryFactory(em);
}
项目:axiom-lib-java    文件:PersistenceContext.java   
@Bean
public JpaRepositoryFactory repositoryFactory(EntityManagerFactory emf) {
    return new JpaRepositoryFactory(emf.createEntityManager());
}
项目:axiom-lib-java    文件:PersistenceContext.java   
@Bean
public AddressStorage addressStorage(JpaRepositoryFactory rf) {
    return rf.getRepository(AddressStorage.class);
}
项目:axiom-lib-java    文件:PersistenceContext.java   
@Bean
public EmailStorage emailStorage(JpaRepositoryFactory rf) {
    return rf.getRepository(EmailStorage.class);
}
项目:axiom-lib-java    文件:PersistenceContext.java   
@Bean
public PhoneStorage phoneStorage(JpaRepositoryFactory rf) {
    return rf.getRepository(PhoneStorage.class);
}