List of usage examples for org.hibernate SharedSessionContract createCriteria
@Deprecated Criteria createCriteria(String entityName);
From source file:com.romeikat.datamessie.core.base.util.publishedDates.PublishedDateStrategy.java
License:Open Source License
private List<LocalDateTime> getAllPublishedTimestamps(final SharedSessionContract ssc) { // Query/* ww w. j av a2 s. co m*/ final Criteria criteria = ssc.createCriteria(Document.class); criteria.add(Restrictions.isNotNull("published")); // Projection criteria.setProjection(Projections.property("published")); // Done @SuppressWarnings("unchecked") final List<LocalDateTime> publishedTimestamps = criteria.list(); return publishedTimestamps; }
From source file:com.thesett.catalogue.core.CatalogueManipulatorBase.java
License:Apache License
/** * Rebuilds all the indexes in the catalgoue in the specified hibernate session. Allowing the hibernate session to * be passed in means that different session setups can be used at config and run time. * * @param session The hibernate session to use. *//*from ww w . j av a2s.co m*/ protected void rebuildIndexesInSession(SharedSessionContract session) { // Empty all the indexes. for (String name : getCatalogue().getAllIndexes()) { clearIndex(name); log.debug("Cleared index: " + name); } // Get a list of all dimensions and loop through them all. for (ComponentType dimension : getCatalogue().getAllComponentTypes()) { // Check that the dimension requires indexing. List<String> indexesForDimension = getCatalogue().getIndexesForDimension(dimension.getName()); if ((indexesForDimension != null) && !indexesForDimension.isEmpty()) { // Extract all data rows from the dimension and loop over them. String entityName = dimension.getName() + Catalogue.ONLINE_TABLE_EXT; Criteria selectCriteria = session.createCriteria(entityName); for (Object entity : selectCriteria.list()) { EntityInstance element = (EntityInstance) entity; // Loop over the list of all indexes that the dimension should be indexed in. for (String indexName : indexesForDimension) { // Insert the element into the index. addToIndex(indexName, ((ExternallyIdentified) element).getExternalId(), element); log.debug("Re-indexed, " + element + ", in index " + indexName); } } } } }