Skip to content
Snippets Groups Projects
Commit 7cbfaf17 authored by Chris Beams's avatar Chris Beams Committed by Mic
Browse files

Fix Petclinic case-sensitivity problems against MySQL (SPR-7512)

With thanks to Rob Winch for patch submission.
parent 0b9d98ba
No related branches found
No related tags found
No related merge requests found
......@@ -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"/>
......
......@@ -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());
......
......@@ -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());
......
......@@ -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>
......@@ -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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment