mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-05-21 19:39:38 +00:00
Fix Petclinic case-sensitivity problems against MySQL (SPR-7512)
With thanks to Rob Winch for patch submission.
This commit is contained in:
parent
0b9d98ba1c
commit
7cbfaf1726
5 changed files with 25 additions and 18 deletions
|
@ -42,10 +42,10 @@
|
||||||
</mapped-superclass>
|
</mapped-superclass>
|
||||||
|
|
||||||
<entity class="Vet">
|
<entity class="Vet">
|
||||||
<table name="VETS"/>
|
<table name="vets"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<many-to-many name="specialtiesInternal" target-entity="Specialty" fetch="EAGER">
|
<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"/>
|
<join-column name="VET_ID"/>
|
||||||
<inverse-join-column name="SPECIALTY_ID"/>
|
<inverse-join-column name="SPECIALTY_ID"/>
|
||||||
</join-table>
|
</join-table>
|
||||||
|
@ -56,11 +56,11 @@
|
||||||
</entity>
|
</entity>
|
||||||
|
|
||||||
<entity class="Specialty">
|
<entity class="Specialty">
|
||||||
<table name="SPECIALTIES"/>
|
<table name="specialties"/>
|
||||||
</entity>
|
</entity>
|
||||||
|
|
||||||
<entity class="Owner">
|
<entity class="Owner">
|
||||||
<table name="OWNERS"/>
|
<table name="owners"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<basic name="address"/>
|
<basic name="address"/>
|
||||||
<basic name="city"/>
|
<basic name="city"/>
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
</entity>
|
</entity>
|
||||||
|
|
||||||
<entity class="Pet">
|
<entity class="Pet">
|
||||||
<table name="PETS"/>
|
<table name="pets"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<basic name="birthDate">
|
<basic name="birthDate">
|
||||||
<column name="BIRTH_DATE"/>
|
<column name="BIRTH_DATE"/>
|
||||||
|
@ -101,11 +101,11 @@
|
||||||
</entity>
|
</entity>
|
||||||
|
|
||||||
<entity class="PetType">
|
<entity class="PetType">
|
||||||
<table name="TYPES"/>
|
<table name="types"/>
|
||||||
</entity>
|
</entity>
|
||||||
|
|
||||||
<entity class="Visit">
|
<entity class="Visit">
|
||||||
<table name="VISITS"/>
|
<table name="visits"/>
|
||||||
<attributes>
|
<attributes>
|
||||||
<basic name="date">
|
<basic name="date">
|
||||||
<column name="VISIT_DATE"/>
|
<column name="VISIT_DATE"/>
|
||||||
|
|
|
@ -92,7 +92,7 @@ public abstract class AbstractClinicTests extends AbstractTransactionalJUnit4Spr
|
||||||
Collection<Vet> vets = this.clinic.getVets();
|
Collection<Vet> vets = this.clinic.getVets();
|
||||||
// Use the inherited countRowsInTable() convenience method (from
|
// Use the inherited countRowsInTable() convenience method (from
|
||||||
// AbstractTransactionalJUnit4SpringContextTests) to verify the results.
|
// 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);
|
Vet v1 = EntityUtils.getById(vets, Vet.class, 2);
|
||||||
assertEquals("Leary", v1.getLastName());
|
assertEquals("Leary", v1.getLastName());
|
||||||
assertEquals(1, v1.getNrOfSpecialties());
|
assertEquals(1, v1.getNrOfSpecialties());
|
||||||
|
@ -107,7 +107,7 @@ public abstract class AbstractClinicTests extends AbstractTransactionalJUnit4Spr
|
||||||
@Test
|
@Test
|
||||||
public void getPetTypes() {
|
public void getPetTypes() {
|
||||||
Collection<PetType> petTypes = this.clinic.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());
|
petTypes.size());
|
||||||
PetType t1 = EntityUtils.getById(petTypes, PetType.class, 1);
|
PetType t1 = EntityUtils.getById(petTypes, PetType.class, 1);
|
||||||
assertEquals("cat", t1.getName());
|
assertEquals("cat", t1.getName());
|
||||||
|
|
|
@ -83,7 +83,7 @@ public abstract class AbstractJpaClinicTests extends AbstractJpaTests {
|
||||||
// Use the inherited countRowsInTable() convenience method (from
|
// Use the inherited countRowsInTable() convenience method (from
|
||||||
// AbstractTransactionalDataSourceSpringContextTests) to verify the
|
// AbstractTransactionalDataSourceSpringContextTests) to verify the
|
||||||
// results.
|
// 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);
|
Vet v1 = EntityUtils.getById(vets, Vet.class, 2);
|
||||||
assertEquals("Leary", v1.getLastName());
|
assertEquals("Leary", v1.getLastName());
|
||||||
assertEquals(1, v1.getNrOfSpecialties());
|
assertEquals(1, v1.getNrOfSpecialties());
|
||||||
|
@ -97,7 +97,7 @@ public abstract class AbstractJpaClinicTests extends AbstractJpaTests {
|
||||||
|
|
||||||
public void testGetPetTypes() {
|
public void testGetPetTypes() {
|
||||||
Collection<PetType> petTypes = this.clinic.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());
|
petTypes.size());
|
||||||
PetType t1 = EntityUtils.getById(petTypes, PetType.class, 1);
|
PetType t1 = EntityUtils.getById(petTypes, PetType.class, 1);
|
||||||
assertEquals("cat", t1.getName());
|
assertEquals("cat", t1.getName());
|
||||||
|
|
|
@ -16,9 +16,12 @@
|
||||||
|
|
||||||
<tx:annotation-driven/>
|
<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.initLocation}"/>
|
||||||
<jdbc:script location="${jdbc.dataLocation}"/>
|
<jdbc:script location="${jdbc.dataLocation}"/>
|
||||||
</jdbc:embedded-database>
|
</jdbc:initialize-database>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
|
@ -14,11 +14,16 @@
|
||||||
|
|
||||||
<tx:annotation-driven />
|
<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.initLocation}"/>
|
||||||
<jdbc:script location="${jdbc.dataLocation}"/>
|
<jdbc:script location="${jdbc.dataLocation}"/>
|
||||||
</jdbc:embedded-database>
|
</jdbc:initialize-database>
|
||||||
|
|
||||||
|
|
||||||
<!-- Note: the specific "jpaAdapter" bean sits in adapter context file -->
|
<!-- Note: the specific "jpaAdapter" bean sits in adapter context file -->
|
||||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
||||||
p:dataSource-ref="dataSource" p:jpaVendorAdapter-ref="jpaAdapter">
|
p:dataSource-ref="dataSource" p:jpaVendorAdapter-ref="jpaAdapter">
|
||||||
|
@ -30,5 +35,4 @@
|
||||||
|
|
||||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
|
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
|
||||||
p:entityManagerFactory-ref="entityManagerFactory" />
|
p:entityManagerFactory-ref="entityManagerFactory" />
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
Loading…
Reference in a new issue