HibernateMetadataVersionStore extends HibernateIdentifiableObjectStore<MetadataVersion> implements MetadataVersionStore { @Override public MetadataVersion getVersionByKey( long key ) { CriteriaBuilder builder = getCriteriaBuilder(); return getSingleResult( builder, newJpaParameters() .addPredicate( root -> builder.equal( root.get( "id" ), key ) ) ); } HibernateMetadataVersionStore( SessionFactory sessionFactory, JdbcTemplate jdbcTemplate,
        ApplicationEventPublisher publisher, CurrentUserService currentUserService, AclService aclService ); @Override MetadataVersion getVersionByKey( long key ); @Override MetadataVersion getVersionByName( String versionName ); @Override MetadataVersion getCurrentVersion(); @Override List<MetadataVersion> getAllVersionsInBetween( Date startDate, Date endDate ); @Override MetadataVersion getInitialVersion();  }
@Test public void testGetVersionByKey() throws Exception { MetadataVersion metadataVersion = new MetadataVersion( "version1", VersionType.ATOMIC ); metadataVersion.setHashCode( "12345" ); metadataVersionStore.save( metadataVersion ); assertEquals( metadataVersion, metadataVersionStore.getVersionByKey( metadataVersionStore.getCurrentVersion().getId() ) ); int nonExistingId = 9999; assertNull( metadataVersionStore.getVersionByKey( nonExistingId ) ); metadataVersionStore.delete( metadataVersion ); }