Skip to content

Commit 029ab02

Browse files
author
sumit.sg34
committed
BAEL-2841 updated code to use multiple xml files
1 parent 93d6d24 commit 029ab02

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

persistence-modules/spring-data-jpa-2/src/main/java/com/baeldung/config/JpaPopulators.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ public Jackson2RepositoryPopulatorFactoryBean getRespositoryPopulator() throws E
2222

2323
@Bean
2424
public UnmarshallerRepositoryPopulatorFactoryBean repositoryPopulator() {
25-
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
26-
marshaller.setClassesToBeBound(Fruit.class);
25+
26+
Jaxb2Marshaller unmarshaller = new Jaxb2Marshaller();
27+
unmarshaller.setClassesToBeBound(Fruit.class);
28+
2729
UnmarshallerRepositoryPopulatorFactoryBean factory = new UnmarshallerRepositoryPopulatorFactoryBean();
28-
factory.setUnmarshaller(marshaller);
29-
factory.setResources(new Resource[] { new ClassPathResource("fruit-data.xml") });
30+
factory.setUnmarshaller(unmarshaller);
31+
factory.setResources(new Resource[] { new ClassPathResource("apple-fruit-data.xml"), new ClassPathResource("guava-fruit-data.xml") });
3032
return factory;
3133
}
3234

persistence-modules/spring-data-jpa-2/src/main/resources/fruit-data.xml renamed to persistence-modules/spring-data-jpa-2/src/main/resources/apple-fruit-data.xml

File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<fruit>
4+
<id>2</id>
5+
<name>guava</name>
6+
<color>green</color>
7+
</fruit>

0 commit comments

Comments
 (0)