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

The following examples show how to use org.springframework.data.jpa.repository.support.JpaEntityInformation. 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
protected SimpleJpaRepository<?, ?> getTargetRepository(RepositoryInformation information,
    EntityManager entityManager) {
  Class<?> domainType = information.getDomainType();
  if (!hasAclStrategyAnnotation(domainType)) {
    return super.getTargetRepository(information, entityManager);
  }

  JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(domainType);

  // invokes
  // com.github.lothar.security.acl.jpa.repository.AclJpaRepository.AclJpaRepository(JpaEntityInformation<T,
  // ?>, EntityManager, JpaSpecProvider<T>)
  SimpleJpaRepository<?, ?> repository = getTargetRepositoryViaReflection(information,
      entityInformation, entityManager, jpaSpecProvider);
  logger.debug("Created {}", repository);

  return repository;
}
 
Example 2
Source Project: sca-best-practice   Source File: CodelessDaoProxy.java    License: Apache License 2.0 5 votes vote down vote up
private <T> JpaEntityInformation<T, ?> getEntityInformation(Class<T> clazz) {
    JpaEntityInformation<T, ?> entityInformation = (JpaEntityInformation<T, ?>)entityInformationMap.get(clazz);
    if (entityInformation != null) {
        return entityInformation;
    }
    entityInformationMap.putIfAbsent(clazz, JpaEntityInformationSupport
        .getEntityInformation(clazz, entityManager));
    return (JpaEntityInformation<T, ?>)entityInformationMap.get(clazz);
}
 
Example 3
Source Project: web-flash   Source File: BaseRepositoryFactoryBean.java    License: MIT License 5 votes vote down vote up
@Override
protected JpaRepositoryImplementation<?, ?> getTargetRepository(RepositoryInformation information, EntityManager entityManager) {
    JpaEntityInformation<?, Serializable> entityInformation = this.getEntityInformation(information.getDomainType());
    Object repository = this.getTargetRepositoryViaReflection(information, new Object[]{entityInformation, entityManager});
    Assert.isInstanceOf(BaseRepositoryImpl.class, repository);
    return (JpaRepositoryImplementation)repository;
}
 
Example 4
Source Project: flash-waimai   Source File: BaseRepositoryFactoryBean.java    License: MIT License 5 votes vote down vote up
@Override
protected JpaRepositoryImplementation<?, ?> getTargetRepository(RepositoryInformation information, EntityManager entityManager) {
    JpaEntityInformation<?, Serializable> entityInformation = this.getEntityInformation(information.getDomainType());
    Object repository = this.getTargetRepositoryViaReflection(information, new Object[]{entityInformation, entityManager});
    Assert.isInstanceOf(BaseRepositoryImpl.class, repository);
    return (JpaRepositoryImplementation)repository;
}
 
Example 5
SimpleExtendedQuerydslJpaRepository(JpaEntityInformation<T, ID> entityInformation,
                                    EntityManager entityManager) throws SQLException {
    super(entityInformation, entityManager, SimpleEntityPathResolver.INSTANCE);
    this.jpaQueryFactory = new JPAQueryFactory(HQLTemplates.DEFAULT, entityManager);
    this.path = SimpleEntityPathResolver.INSTANCE.createPath(entityInformation.getJavaType());
    SQLTemplates sqlTemplates = getSQLServerTemplates(entityManager.getEntityManagerFactory());
    this.jpaSqlFactory = () -> new JPASQLQuery<>(entityManager, sqlTemplates);
    this.entityManager = entityManager;
}
 
Example 6
@Before
public void setup(){
    JpaEntityInformation<TestEntity, Integer> information = new JpaMetamodelEntityInformation<>(
            TestEntity.class, em.getMetamodel());
    repository = new SimpleJpaRepository<>(information, em);
    entities = SpecificationBuilder.selectDistinctFrom(repository).where(new Filter("string",EQUAL,"a")).findAll();
    Assert.assertTrue(entities.size() >= 1);
}
 
Example 7
public GenericJpaRepositoryImpl(JpaEntityInformation<T, ID> eif, EntityManager em) {
    super(eif, em);
    this.eif = eif;
    PropertyDescriptor descriptor = findFieldPropertyDescriptor(eif.getJavaType(), Status.class);
    isStatusAble = descriptor != null;
    if (isStatusAble) {
        statusReadMethod = descriptor.getReadMethod();
        statusWriteMethod = descriptor.getWriteMethod();
    }
}
 
Example 8
@SuppressWarnings("unchecked")
public EntityGraphQuerydslRepository(
    JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
  super(entityInformation, entityManager);
  this.querydslJpaRepositoryDelegate =
      new EntityGraphAwareQuerydslJpaRepository<>(
          (JpaEntityInformation<T, ID>) entityInformation, entityManager);
}
 
Example 9
public EntityGraphQuerydslRepository(
    JpaEntityInformation<T, ID> entityInformation,
    EntityManager entityManager,
    EntityPathResolver resolver) {
  super(entityInformation, entityManager);
  this.querydslJpaRepositoryDelegate =
      new EntityGraphAwareQuerydslJpaRepository<>(entityInformation, entityManager, resolver);
}
 
Example 10
@Test
public void repositoriesAreAssignedToAppropriateStores() {

	Repositories repositories = new Repositories(context);

	assertThat(repositories.getEntityInformationFor(Customer.class), is(instanceOf(JpaEntityInformation.class)));
	assertThat(repositories.getEntityInformationFor(Order.class), is(instanceOf(MongoEntityInformation.class)));
}
 
Example 11
/**
 * Creates a new {@link SimpleJpaRepository} to manage objects of the given
 * {@link JpaEntityInformation}.
 */
public GenericRepositoryImpl(final JpaEntityInformation<T, ?> entityInformation, final EntityManager entityManager,
        final NamedQueryUtil namedQueryUtil) {
    super(entityInformation, entityManager);
    this.entityInformation = entityInformation;
    this.em = entityManager;
    // provider =
    // DefaultPersistenceProvider.fromEntityManager(entityManager);
    // this.springDataRepositoryInterface = springDataRepositoryInterface;
    this.namedQueryUtil = namedQueryUtil;
    this.byExampleSpecification = new ByExampleSpecification(entityManager);
}
 
Example 12
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected <T, ID extends Serializable> SimpleJpaRepository<?, ?> getTargetRepository(
        final RepositoryMetadata metadata, final EntityManager entityManager) {

    Class<?> repositoryInterface = metadata.getRepositoryInterface();

    JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType());

    if (isQueryDslExecutor(repositoryInterface)) {
        return new QueryDslJpaRepository(entityInformation, entityManager);
    } else {
        return new GenericRepositoryImpl(entityInformation, entityManager, namedQueryUtil); // custom
    }
}
 
Example 13
Source Project: es   Source File: SimpleBaseRepository.java    License: Apache License 2.0 5 votes vote down vote up
public SimpleBaseRepository(JpaEntityInformation<M, ID> entityInformation, EntityManager entityManager) {
    super(entityInformation, entityManager);

    this.entityInformation = entityInformation;
    this.entityClass = this.entityInformation.getJavaType();
    this.entityName = this.entityInformation.getEntityName();
    this.idName = this.entityInformation.getIdAttributeNames().iterator().next();
    this.em = entityManager;

    repositoryHelper = new RepositoryHelper(entityClass);

    findAllQL = String.format(FIND_QUERY_STRING, entityName);
    countAllQL = String.format(COUNT_QUERY_STRING, entityName);
}
 
Example 14
Source Project: es   Source File: SimpleBaseRepositoryFactoryBean.java    License: Apache License 2.0 5 votes vote down vote up
protected Object getTargetRepository(RepositoryMetadata metadata) {
    Class<?> repositoryInterface = metadata.getRepositoryInterface();

    if (isBaseRepository(repositoryInterface)) {

        JpaEntityInformation<M, ID> entityInformation = getEntityInformation((Class<M>) metadata.getDomainType());
        SimpleBaseRepository repository = new SimpleBaseRepository<M, ID>(entityInformation, entityManager);

        SearchableQuery searchableQuery = AnnotationUtils.findAnnotation(repositoryInterface, SearchableQuery.class);
        if (searchableQuery != null) {
            String countAllQL = searchableQuery.countAllQuery();
            if (!StringUtils.isEmpty(countAllQL)) {
                repository.setCountAllQL(countAllQL);
            }
            String findAllQL = searchableQuery.findAllQuery();
            if (!StringUtils.isEmpty(findAllQL)) {
                repository.setFindAllQL(findAllQL);
            }
            Class<? extends SearchCallback> callbackClass = searchableQuery.callbackClass();
            if (callbackClass != null && callbackClass != SearchCallback.class) {
                repository.setSearchCallback(BeanUtils.instantiate(callbackClass));
            }

            repository.setJoins(searchableQuery.joins());

        }

        return repository;
    }
    return super.getTargetRepository(metadata);
}
 
Example 15
Source Project: sca-best-practice   Source File: CodelessDaoProxy.java    License: Apache License 2.0 4 votes vote down vote up
ByIdsSpecification(JpaEntityInformation<T, ?> entityInformation) {
    this.entityInformation = entityInformation;
}
 
Example 16
Source Project: web-flash   Source File: BaseRepositoryImpl.java    License: MIT License 4 votes vote down vote up
BaseRepositoryImpl(JpaEntityInformation<T, ID> entityInformation,
                   EntityManager entityManager) {
    super(entityInformation, entityManager);
    this.entityManager = entityManager;
    this.klass = (Class<T>) entityInformation.getJavaType();
}
 
Example 17
Source Project: flash-waimai   Source File: BaseRepositoryImpl.java    License: MIT License 4 votes vote down vote up
BaseRepositoryImpl(JpaEntityInformation<T, ID> entityInformation,
                   EntityManager entityManager) {
    super(entityInformation, entityManager);
    this.entityManager = entityManager;
    this.klass = (Class<T>) entityInformation.getJavaType();
}
 
Example 18
Source Project: Spring   Source File: ExtendedRepositoryImpl.java    License: Apache License 2.0 4 votes vote down vote up
public ExtendedRepositoryImpl(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
	super(entityInformation, entityManager);
	this.entityInformation = entityInformation;
	this.entityManager = entityManager;
}
 
Example 19
Source Project: halo   Source File: BaseRepositoryImpl.java    License: GNU General Public License v3.0 4 votes vote down vote up
public BaseRepositoryImpl(JpaEntityInformation<DOMAIN, ID> entityInformation, EntityManager entityManager) {
    super(entityInformation, entityManager);
    this.entityInformation = entityInformation;
    this.entityManager = entityManager;
}
 
Example 20
Source Project: halo   Source File: BaseRepositoryImpl.java    License: GNU General Public License v3.0 4 votes vote down vote up
ByIdsSpecification(JpaEntityInformation<T, ?> entityInformation) {
    this.entityInformation = entityInformation;
}
 
Example 21
Source Project: galeb   Source File: VirtualHostRepositoryImpl.java    License: Apache License 2.0 4 votes vote down vote up
private boolean entityIsNew(VirtualHost virtualHost) {
    JpaEntityInformation<VirtualHost, ?> entityInformation = JpaEntityInformationSupport
            .getEntityInformation(VirtualHost.class, genericDaoService.entityManager());

    return entityInformation.isNew(virtualHost);
}
 
Example 22
Source Project: docs-manage   Source File: BaseRepositoryImpl.java    License: MIT License 4 votes vote down vote up
public BaseRepositoryImpl(JpaEntityInformation<E, PK> entityInformation, EntityManager entityManager) {
    super(entityInformation, entityManager);
    this.entityManager = entityManager;
}
 
Example 23
Source Project: sample-boot-micro   Source File: OrmTemplate.java    License: MIT License 4 votes vote down vote up
/** 指定したエンティティの ID 値を取得します。 */
@SuppressWarnings("unchecked")
public <T> Serializable idValue(T entity) {
    return ((JpaEntityInformation<T, Serializable>)OrmUtils.entityInformation(em, entity.getClass())).getId(entity);
}
 
Example 24
public JpaSpecificationExecutorWithProjectionImpl(JpaEntityInformation entityInformation, EntityManager entityManager) {
    super(entityInformation, entityManager);
    this.entityManager = entityManager;
    this.entityInformation = entityInformation;
}
 
Example 25
Source Project: java-platform   Source File: BaseRepositoryImpl.java    License: Apache License 2.0 4 votes vote down vote up
public BaseRepositoryImpl(JpaEntityInformation<T, I> entityInformation, EntityManager entityManager) {
	super(entityInformation, entityManager);
}
 
Example 26
Source Project: java-platform   Source File: TreeRepositoryImpl.java    License: Apache License 2.0 4 votes vote down vote up
public TreeRepositoryImpl(JpaEntityInformation<T, I> entityInformation, EntityManager entityManager) {
	super(entityInformation, entityManager);
}
 
Example 27
public AclJpaRepository(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager,
    JpaSpecProvider<T> jpaSpecProvider) {
  super(entityInformation, entityManager);
  this.jpaSpecProvider = jpaSpecProvider;
}
 
Example 28
public GenericRepositoryImpl(JpaEntityInformation<E, ?> entityInformation, EntityManager entityManager) {
	super(entityInformation, entityManager);
	this.em = entityManager;
}
 
Example 29
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected <T, ID extends Serializable> SimpleJpaRepository<?, ?> getTargetRepository(RepositoryMetadata metadata, EntityManager entityManager) {
	JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType());
	return new GenericRepositoryImpl(entityInformation, entityManager);
}
 
Example 30
Source Project: genericdao   Source File: GenericJpaRepositoryImpl.java    License: Artistic License 2.0 4 votes vote down vote up
public GenericJpaRepositoryImpl(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager){
	super(entityInformation, entityManager);
	this.entityInformation = entityInformation;
	this.entityManager = entityManager;
}