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 19 ■ <strong>Spring</strong> Boot, Simplifying Everything<br />

@Bean<br />

public DataSource dataSource() {<br />

EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();<br />

EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.HSQL).<br />

addScript("META-INF/data/schema.sql").<br />

addScript("META-INF/data/data.sql").build();<br />

return db;<br />

}<br />

}<br />

Listing 19-2 shows the JDBC Config, which you will need at some point because you are using an in-memory<br />

database, and you are showing that you can still use XML files from other projects. In this case, you are going to use<br />

only one, the jdbc-context.xml that only contains the SQL statements. Listing 19-3 shows this file.<br />

Listing 19-3. jdbc-context.xml<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

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

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

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

documents d<br />

join types t<br />

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

<br />

<br />

<br />

<br />

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

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

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

documents d<br />

join types t<br />

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

where d.documentId = ?<br />

<br />

<br />

<br />

<br />

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

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

265

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

Saved successfully!

Ooh no, something went wrong!