Skip to content

Commit

Permalink
Make load script work in native image
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Oct 9, 2018
1 parent 95c6a78 commit 42891ba
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public final class HibernateResourceProcessor implements ResourceProcessor {

@Override
public void process(final ArchiveContext archiveContext, final ProcessorContext processorContext) throws Exception {

List<ParsedPersistenceXmlDescriptor> descriptors = PersistenceUnitsHolder.loadOriginalXMLParsedDescriptors();
processorContext.setProperty(PARSED_DESCRIPTORS, descriptors);

Expand All @@ -55,6 +54,14 @@ public void process(final ArchiveContext archiveContext, final ProcessorContext
classDescriptors.add(desc);
}
scanner.setClassDescriptors(classDescriptors);
for(ParsedPersistenceXmlDescriptor i : descriptors) {
//add resources
if(i.getProperties().containsKey("javax.persistence.sql-load-script-source")) {
processorContext.addResource((String) i.getProperties().get("javax.persistence.sql-load-script-source"));
} else {
processorContext.addResource("import.sql");
}
}

try (BytecodeRecorder recorder = processorContext.addStaticInitTask(RuntimePriority.JPA_DEPLOYMENT)) {
//now we serialize the XML and class list to bytecode, to remove the need to re-parse the XML on JVM startup
Expand Down

0 comments on commit 42891ba

Please sign in to comment.