/** * Binds the entity class if not yet bound. * @param entityClass the class to bind. */ private void bindIfUnbound(Class<?> entityClass) { if (! entityBindings.containsKey(lookupEntityClass(entityClass))) { bindEntity(entityClass); } } }
/** * Binds the entity class if not yet bound. * @param entityClass the class to bind. */ private void bindIfUnbound(Class<?> entityClass) { if (! entityBindings.containsKey(lookupEntityClass(entityClass))) { bindEntity(entityClass); } } }
@BeforeClass public void initialize() { dictionary = new EntityDictionary(new HashMap<>()); dictionary.bindEntity(Book.class); dictionary.bindEntity(Author.class); dictionary.bindEntity(Publisher.class); dictionary.bindEntity(Chapter.class); }
@Override public void populateEntityDictionary(EntityDictionary dictionary) { /* bind all entities */ for (ClassMetadata meta : sessionFactory.getAllClassMetadata().values()) { dictionary.bindEntity(meta.getMappedClass(EntityMode.POJO)); } }
@BeforeClass public void initialize() { dictionary = new EntityDictionary(new HashMap<>()); dictionary.bindEntity(Book.class); dictionary.bindEntity(Author.class); dictionary.bindEntity(Publisher.class); dictionary.bindEntity(Chapter.class); }
@BeforeClass public void initialize() { dictionary = new EntityDictionary(new HashMap<>()); dictionary.bindEntity(Book.class); dictionary.bindEntity(Author.class); dictionary.bindEntity(Publisher.class); dictionary.bindEntity(Chapter.class); }
@BeforeClass public void initialize() { dictionary = new EntityDictionary(new HashMap<>()); dictionary.bindEntity(Book.class); dictionary.bindEntity(Author.class); dictionary.bindEntity(Publisher.class); dictionary.bindEntity(Chapter.class); }
public AbstractHQLQueryBuilderTest() { super(new EntityDictionary(new HashMap<>()), new TestSessionWrapper()); dictionary.bindEntity(Author.class); dictionary.bindEntity(Book.class); dictionary.bindEntity(Chapter.class); dictionary.bindEntity(Publisher.class); dictionary.bindEntity(Left.class); }
@Override public void populateEntityDictionary(EntityDictionary dictionary) { Reflections reflections = new Reflections(new ConfigurationBuilder() .addUrls(ClasspathHelper.forPackage(beanPackage.getName())) .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner())); reflections.getTypesAnnotatedWith(Entity.class).stream() .filter(entityAnnotatedClass -> entityAnnotatedClass.getPackage().getName() .startsWith(beanPackage.getName())) .forEach((cls) -> { dictionary.bindEntity(cls); dataStore.put(cls, Collections.synchronizedMap(new LinkedHashMap<>())); }); this.dictionary = dictionary; }
protected void bindEntity(EntityDictionary dictionary, EntityType type) { try { Class mappedClass = type.getJavaType(); // Ignore this result. We are just checking to see if it throws an exception meaning that // provided class was _not_ an entity. dictionary.lookupEntityClass(mappedClass); // Bind if successful dictionary.bindEntity(mappedClass); } catch (IllegalArgumentException e) { // Ignore this entity // Turns out that hibernate may include non-entity types in this list when using things // like envers. Since they are not entities, we do not want to bind them into the entity // dictionary } }
@Override public void populateEntityDictionary(EntityDictionary dictionary) { Reflections reflections = new Reflections(new ConfigurationBuilder() .addUrls(ClasspathHelper.forPackage(beanPackage.getName())) .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner())); reflections.getTypesAnnotatedWith(Entity.class).stream() .filter(entityAnnotatedClass -> entityAnnotatedClass.getPackage().getName() .startsWith(beanPackage.getName())) .forEach((cls) -> { dictionary.bindEntity(cls); dataStore.put(cls, Collections.synchronizedMap(new LinkedHashMap<>())); }); this.dictionary = dictionary; }
protected void bindEntity(EntityDictionary dictionary, EntityType type) { try { Class mappedClass = type.getJavaType(); // Ignore this result. We are just checking to see if it throws an exception meaning that // provided class was _not_ an entity. dictionary.lookupEntityClass(mappedClass); // Bind if successful dictionary.bindEntity(mappedClass); } catch (IllegalArgumentException e) { // Ignore this entity // Turns out that hibernate may include non-entity types in this list when using things // like envers. Since they are not entities, we do not want to bind them into the entity // dictionary } }
@Override public void populateEntityDictionary(EntityDictionary dictionary) { this.dictionary = dictionary; for (DataStore dataStore : dataStores) { EntityDictionary subordinateDictionary = new EntityDictionary(dictionary.getCheckMappings()); dataStore.populateEntityDictionary(subordinateDictionary); for (Class<?> cls : subordinateDictionary.getBindings()) { // route class to this database manager this.dataStoreMap.put(cls, dataStore); // bind to multiplex dictionary dictionary.bindEntity(cls); dictionary.bindInitializer(subordinateDictionary::initializeEntity, cls); } } }
dictionary.bindEntity(mappedClass); } catch (IllegalArgumentException e) {
@Test (dataProvider = "like_queries_hql") public void testSpecialCharacterLikeQueryHQL(FilterPredicate filterPredicate, int noOfRecords) throws Exception { DataStoreTransaction tx = dataStore.beginReadTransaction(); RequestScope scope = mock(RequestScope.class); EntityDictionary dictionary = new EntityDictionary(new HashMap<>()); dictionary.bindEntity(Book.class); when(scope.getDictionary()).thenReturn(dictionary); Pagination pagination = mock(Pagination.class); when(pagination.isGenerateTotals()).thenReturn(true); tx.loadObjects(Book.class, Optional.of(filterPredicate), Optional.empty(), Optional.of(pagination), scope); tx.commit(scope); tx.close(); verify(pagination).setPageTotals(noOfRecords); }