25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 9 ■ Adding Persistence to Your <strong>Spring</strong> Application<br />

xsi:schemaLocation="http://www.springframework.org/schema/jdbc<br />

http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd<br />

http://www.springframework.org/schema/beans<br />

http://www.springframework.org/schema/beans/spring-beans.xsd<br />

http://www.springframework.org/schema/context<br />

http://www.springframework.org/schema/context/spring-context-4.0.xsd"><br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

select d.documentId, d.name, d.location, d.description as doc_desc, d.typeId,<br />

d.created, d.modified,<br />

t.name as type_name, t.description as type_desc, t.extension from documents d<br />

join types t<br />

on d.typeId = t.typeId<br />

<br />

<br />

<br />

<br />

In Listing 9-17, you set the DocumentDAO bean reference to the DocumentJdbcTemplateRepository class;<br />

practically nothing changes except this reference to the class. Next, let’s create the unit test class (see Listing 9-18).<br />

Listing 9-18. MyDocumentsJDBCTemplateTest.java<br />

package com.apress.isf.spring.test;<br />

import static org.junit.Assert.assertEquals;<br />

import static org.junit.Assert.assertNotNull;<br />

import static org.junit.Assert.assertTrue;<br />

import java.util.List;<br />

import org.junit.Test;<br />

import org.junit.runner.RunWith;<br />

import org.springframework.beans.factory.annotation.Autowired;<br />

import org.springframework.test.context.ContextConfiguration;<br />

import org.springframework.test.context.junit4.<strong>Spring</strong>JUnit4ClassRunner;<br />

131

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!