felles/db/src/main/java/no/nav/vedtak/felles/jpa/VLPersistenceUnitProvider.java
/** Add additional mapping files based on naming convention. */
Add additional mapping files based on naming convention.
Add additional mapping files based on naming convention .
protected PersistenceUnitDescriptor extendPersistenceUnitDescriptor(PersistenceUnitDescriptor pud) {
        class AdditionalMappingFilesPersistenceUnitDescriptor extends DelegatingPersistenceUnitDescriptor {
            private final List<String> mappingFiles = new ArrayList<>();
            AdditionalMappingFilesPersistenceUnitDescriptor(PersistenceUnitDescriptor pud) {
                super(pud);
                mappingFiles.addAll(pud.getMappingFileNames());
            }
            @Override
            public List<String> getMappingFileNames() {
                return this.mappingFiles;
            }
            void addMappingFileNames(Collection<String> mappingFileNames) {
                this.mappingFiles.addAll(mappingFileNames);
            }
        }
        try {
            Pattern ormPattern = Pattern.compile("^META-INF/" + pud.getName() + "\\..+\\.orm\\.xml$");
            Set<String> ormFiles = getResourceFolderFiles("META-INF", ormPattern);
            ormFiles.forEach(f -> LOG.info("Found ORM mapping file: {}", f));
            AdditionalMappingFilesPersistenceUnitDescriptor newPud = new AdditionalMappingFilesPersistenceUnitDescriptor(pud);
            newPud.addMappingFileNames(ormFiles);
            return newPud;
        } catch (IOException | URISyntaxException e) {
            throw new IllegalArgumentException("Could not load ORM files for persistence unit " + pud.getName(), e);
        }
    }
protected PersistenceUnitDescriptor extendPersistenceUnitDescriptor ( PersistenceUnitDescriptor pud ) { class AdditionalMappingFilesPersistenceUnitDescriptor extends DelegatingPersistenceUnitDescriptor { private final List < String > mappingFiles = new ArrayList < > ( ) ; AdditionalMappingFilesPersistenceUnitDescriptor ( PersistenceUnitDescriptor pud ) { super ( pud ) ; mappingFiles . addAll ( pud . getMappingFileNames ( ) ) ; } @ Override public List < String > getMappingFileNames ( ) { return this . mappingFiles ; } void addMappingFileNames ( Collection < String > mappingFileNames ) { this . mappingFiles . addAll ( mappingFileNames ) ; } } try { Pattern ormPattern = Pattern . compile ( "^META-INF/" + pud . getName ( ) + "\\..+\\.orm\\.xml$" ) ; Set < String > ormFiles = getResourceFolderFiles ( "META-INF" , ormPattern ) ; ormFiles . forEach ( f -> LOG . info ( "Found ORM mapping file: {}" , f ) ) ; AdditionalMappingFilesPersistenceUnitDescriptor newPud = new AdditionalMappingFilesPersistenceUnitDescriptor ( pud ) ; newPud . addMappingFileNames ( ormFiles ) ; return newPud ; } catch ( IOException | URISyntaxException e ) { throw new IllegalArgumentException ( "Could not load ORM files for persistence unit " + pud . getName ( ) , e ) ; } }
Add additional mapping files based on naming convention.
Add additional mapping files based on naming convention .