diff --git a/src/main/resources/META-INF/orm.xml b/src/main/resources/META-INF/orm.xml index d7c8f7040a13f121824717b763d879068e24233c..7ea243ecf1a012e60c8c04009c758a4c3f74ead6 100644 --- a/src/main/resources/META-INF/orm.xml +++ b/src/main/resources/META-INF/orm.xml @@ -42,10 +42,10 @@ </mapped-superclass> <entity class="Vet"> - <table name="VETS"/> + <table name="vets"/> <attributes> <many-to-many name="specialtiesInternal" target-entity="Specialty" fetch="EAGER"> - <join-table name="VET_SPECIALTIES"> + <join-table name="vet_specialties"> <join-column name="VET_ID"/> <inverse-join-column name="SPECIALTY_ID"/> </join-table> @@ -56,11 +56,11 @@ </entity> <entity class="Specialty"> - <table name="SPECIALTIES"/> + <table name="specialties"/> </entity> <entity class="Owner"> - <table name="OWNERS"/> + <table name="owners"/> <attributes> <basic name="address"/> <basic name="city"/> @@ -75,7 +75,7 @@ </entity> <entity class="Pet"> - <table name="PETS"/> + <table name="pets"/> <attributes> <basic name="birthDate"> <column name="BIRTH_DATE"/> @@ -101,11 +101,11 @@ </entity> <entity class="PetType"> - <table name="TYPES"/> + <table name="types"/> </entity> <entity class="Visit"> - <table name="VISITS"/> + <table name="visits"/> <attributes> <basic name="date"> <column name="VISIT_DATE"/> diff --git a/src/test/java/org/springframework/samples/petclinic/AbstractClinicTests.java b/src/test/java/org/springframework/samples/petclinic/AbstractClinicTests.java index a698691867a90b98be6dd03edca171e71f1790f2..63010dc34283bc7570d54def97e4370311c82427 100644 --- a/src/test/java/org/springframework/samples/petclinic/AbstractClinicTests.java +++ b/src/test/java/org/springframework/samples/petclinic/AbstractClinicTests.java @@ -92,7 +92,7 @@ public abstract class AbstractClinicTests extends AbstractTransactionalJUnit4Spr Collection<Vet> vets = this.clinic.getVets(); // Use the inherited countRowsInTable() convenience method (from // AbstractTransactionalJUnit4SpringContextTests) to verify the results. - assertEquals("JDBC query must show the same number of vets", super.countRowsInTable("VETS"), vets.size()); + assertEquals("JDBC query must show the same number of vets", super.countRowsInTable("vets"), vets.size()); Vet v1 = EntityUtils.getById(vets, Vet.class, 2); assertEquals("Leary", v1.getLastName()); assertEquals(1, v1.getNrOfSpecialties()); @@ -107,7 +107,7 @@ public abstract class AbstractClinicTests extends AbstractTransactionalJUnit4Spr @Test public void getPetTypes() { Collection<PetType> petTypes = this.clinic.getPetTypes(); - assertEquals("JDBC query must show the same number of pet types", super.countRowsInTable("TYPES"), + assertEquals("JDBC query must show the same number of pet types", super.countRowsInTable("types"), petTypes.size()); PetType t1 = EntityUtils.getById(petTypes, PetType.class, 1); assertEquals("cat", t1.getName()); diff --git a/src/test/java/org/springframework/samples/petclinic/jpa/AbstractJpaClinicTests.java b/src/test/java/org/springframework/samples/petclinic/jpa/AbstractJpaClinicTests.java index d8adc91831345630bd2c21cdf621ce08aa3c3534..335297d9001d778f43aca21cb69d1389306b5cb7 100644 --- a/src/test/java/org/springframework/samples/petclinic/jpa/AbstractJpaClinicTests.java +++ b/src/test/java/org/springframework/samples/petclinic/jpa/AbstractJpaClinicTests.java @@ -83,7 +83,7 @@ public abstract class AbstractJpaClinicTests extends AbstractJpaTests { // Use the inherited countRowsInTable() convenience method (from // AbstractTransactionalDataSourceSpringContextTests) to verify the // results. - assertEquals("JDBC query must show the same number of vets", super.countRowsInTable("VETS"), vets.size()); + assertEquals("JDBC query must show the same number of vets", super.countRowsInTable("vets"), vets.size()); Vet v1 = EntityUtils.getById(vets, Vet.class, 2); assertEquals("Leary", v1.getLastName()); assertEquals(1, v1.getNrOfSpecialties()); @@ -97,7 +97,7 @@ public abstract class AbstractJpaClinicTests extends AbstractJpaTests { public void testGetPetTypes() { Collection<PetType> petTypes = this.clinic.getPetTypes(); - assertEquals("JDBC query must show the same number of pet types", super.countRowsInTable("TYPES"), + assertEquals("JDBC query must show the same number of pet types", super.countRowsInTable("types"), petTypes.size()); PetType t1 = EntityUtils.getById(petTypes, PetType.class, 1); assertEquals("cat", t1.getName()); diff --git a/src/test/resources/org/springframework/samples/petclinic/AbstractClinicTests-context.xml b/src/test/resources/org/springframework/samples/petclinic/AbstractClinicTests-context.xml index a0bc4bd00d4d7ffeb0b82efa36e59f8576f825fc..d048d8ae0b1d387ace8647abbdca0e91aa1fb217 100644 --- a/src/test/resources/org/springframework/samples/petclinic/AbstractClinicTests-context.xml +++ b/src/test/resources/org/springframework/samples/petclinic/AbstractClinicTests-context.xml @@ -16,9 +16,12 @@ <tx:annotation-driven/> - <jdbc:embedded-database id="dataSource"> + <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" + p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" + p:username="${jdbc.username}" p:password="${jdbc.password}"/> + + <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"> <jdbc:script location="${jdbc.initLocation}"/> <jdbc:script location="${jdbc.dataLocation}"/> - </jdbc:embedded-database> - + </jdbc:initialize-database> </beans> diff --git a/src/test/resources/org/springframework/samples/petclinic/jpa/applicationContext-jpaCommon.xml b/src/test/resources/org/springframework/samples/petclinic/jpa/applicationContext-jpaCommon.xml index f5fbe563f5e31c93815e338622364ea7b353e4c3..3202f94c527fe314b29b2a9138e5d80d97a60e32 100644 --- a/src/test/resources/org/springframework/samples/petclinic/jpa/applicationContext-jpaCommon.xml +++ b/src/test/resources/org/springframework/samples/petclinic/jpa/applicationContext-jpaCommon.xml @@ -14,11 +14,16 @@ <tx:annotation-driven /> - <jdbc:embedded-database id="dataSource"> + <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" + p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" + p:username="${jdbc.username}" p:password="${jdbc.password}"/> + + <jdbc:initialize-database data-source="dataSource"> <jdbc:script location="${jdbc.initLocation}"/> <jdbc:script location="${jdbc.dataLocation}"/> - </jdbc:embedded-database> - + </jdbc:initialize-database> + + <!-- Note: the specific "jpaAdapter" bean sits in adapter context file --> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:dataSource-ref="dataSource" p:jpaVendorAdapter-ref="jpaAdapter"> @@ -30,5 +35,4 @@ <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="entityManagerFactory" /> - </beans>