@@ -0,0 +1,2126 @@
+package com.vladmihalcea.book.hpjp.hibernate.metadata;%0A%0Aimport java.util.Collection;%0Aimport javax.persistence.Entity;%0Aimport javax.persistence.Id;%0A%0Aimport org.hibernate.annotations.DynamicUpdate;%0Aimport org.hibernate.boot.Metadata;%0Aimport org.hibernate.boot.model.relational.Database;%0Aimport org.hibernate.boot.model.relational.Namespace;%0Aimport org.hibernate.engine.spi.SessionFactoryImplementor;%0Aimport org.hibernate.integrator.spi.Integrator;%0Aimport org.hibernate.mapping.Table;%0Aimport org.hibernate.service.spi.SessionFactoryServiceRegistry;%0A%0Aimport org.junit.Test;%0A%0Aimport com.vladmihalcea.book.hpjp.util.AbstractTest;%0Aimport com.vladmihalcea.book.hpjp.util.EntityProvider;%0Aimport com.vladmihalcea.book.hpjp.util.providers.entity.BlogEntityProvider;%0A%0A/**%0A * @author Vlad Mihalcea%0A */%0Apublic class MetadataTest extends AbstractTest %7B%0A%0A    public static class MetadataExtractorIntegrator implements org.hibernate.integrator.spi.Integrator %7B%0A%0A        public static final MetadataExtractorIntegrator INSTANCE = new MetadataExtractorIntegrator();%0A%0A        private Database database;%0A%0A        @Override%0A        public void integrate(%0A                Metadata metadata,%0A                SessionFactoryImplementor sessionFactory,%0A                SessionFactoryServiceRegistry serviceRegistry) %7B%0A%0A            database = metadata.getDatabase();%0A        %7D%0A%0A        @Override%0A        public void disintegrate(%0A            SessionFactoryImplementor sessionFactory,%0A            SessionFactoryServiceRegistry serviceRegistry) %7B%0A%0A        %7D%0A%0A        public Database getDatabase() %7B%0A            return database;%0A        %7D%0A    %7D%0A%0A    @Override%0A    protected Integrator integrator() %7B%0A        return MetadataExtractorIntegrator.INSTANCE;%0A    %7D%0A%0A    @Override%0A    protected Class%3C?%3E%5B%5D entities() %7B%0A        return new BlogEntityProvider().entities();%0A    %7D%0A%0A    @Test%0A    public void test() %7B%0A        for(Namespace namespace : MetadataExtractorIntegrator.INSTANCE.getDatabase().getNamespaces()) %7B%0A            for( Table table : namespace.getTables()) %7B%0A                LOGGER.info( %22Mapping table: %7B%7D%22, table );%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add MetadataTest