Skip to content

Commit b55bc62

Browse files
committed
Merge remote-tracking branch 'refs/remotes/eugenp/master' into XStream-XML-to-Object
2 parents cbc3d11 + 9aff816 commit b55bc62

34 files changed

Lines changed: 359 additions & 361 deletions

‎jooq-spring/pom.xml‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<properties>
99
<org.jooq.version>3.7.3</org.jooq.version>
1010
<com.h2database.version>1.4.191</com.h2database.version>
11-
<com.zaxxer.HikariCP.version>2.4.4</com.zaxxer.HikariCP.version>
1211
<org.springframework.version>4.2.5.RELEASE</org.springframework.version>
1312
<org.slf4j.version>1.7.18</org.slf4j.version>
1413
<ch.qos.logback.version>1.1.3</ch.qos.logback.version>
@@ -29,11 +28,6 @@
2928
<artifactId>h2</artifactId>
3029
<version>${com.h2database.version}</version>
3130
</dependency>
32-
<dependency>
33-
<groupId>com.zaxxer</groupId>
34-
<artifactId>HikariCP</artifactId>
35-
<version>${com.zaxxer.HikariCP.version}</version>
36-
</dependency>
3731

3832
<!-- Spring -->
3933
<dependency>

‎jooq-spring/src/test/java/com/baeldung/jooq/introduction/PersistenceContext.java‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package com.baeldung.jooq.introduction;
22

33
import javax.sql.DataSource;
4-
import com.zaxxer.hikari.HikariDataSource;
5-
4+
import org.h2.jdbcx.JdbcDataSource;
65
import org.jooq.SQLDialect;
76
import org.jooq.impl.DataSourceConnectionProvider;
87
import org.jooq.impl.DefaultConfiguration;
98
import org.jooq.impl.DefaultDSLContext;
109
import org.jooq.impl.DefaultExecuteListenerProvider;
11-
1210
import org.springframework.beans.factory.annotation.Autowired;
1311
import org.springframework.context.annotation.Bean;
1412
import org.springframework.context.annotation.ComponentScan;
@@ -29,11 +27,10 @@ public class PersistenceContext {
2927

3028
@Bean
3129
public DataSource dataSource() {
32-
HikariDataSource dataSource = new HikariDataSource();
33-
34-
dataSource.setDriverClassName(environment.getRequiredProperty("db.driver"));
35-
dataSource.setJdbcUrl(environment.getRequiredProperty("db.url"));
36-
dataSource.setUsername(environment.getRequiredProperty("db.username"));
30+
JdbcDataSource dataSource = new JdbcDataSource();
31+
32+
dataSource.setUrl(environment.getRequiredProperty("db.url"));
33+
dataSource.setUser(environment.getRequiredProperty("db.username"));
3734
dataSource.setPassword(environment.getRequiredProperty("db.password"));
3835

3936
return dataSource;
Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
11
package com.baeldung.jooq.introduction;
22

3-
import static org.junit.Assert.assertEquals;
4-
5-
import org.junit.Test;
6-
import org.junit.runner.RunWith;
7-
3+
import com.baeldung.jooq.introduction.db.public_.tables.Author;
4+
import com.baeldung.jooq.introduction.db.public_.tables.AuthorBook;
5+
import com.baeldung.jooq.introduction.db.public_.tables.Book;
86
import org.jooq.DSLContext;
97
import org.jooq.Record3;
108
import org.jooq.Result;
119
import org.jooq.impl.DSL;
12-
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
1312
import org.springframework.beans.factory.annotation.Autowired;
1413
import org.springframework.dao.DataAccessException;
1514
import org.springframework.test.context.ContextConfiguration;
1615
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1716
import org.springframework.transaction.annotation.Transactional;
1817

19-
import com.baeldung.jooq.introduction.db.public_.tables.Author;
20-
import com.baeldung.jooq.introduction.db.public_.tables.AuthorBook;
21-
import com.baeldung.jooq.introduction.db.public_.tables.Book;
18+
import static org.junit.Assert.assertEquals;
2219

2320
@ContextConfiguration(classes = PersistenceContext.class)
2421
@Transactional(transactionManager = "transactionManager")
2522
@RunWith(SpringJUnit4ClassRunner.class)
2623
public class QueryTest {
24+
2725
@Autowired
28-
private DSLContext create;
26+
private DSLContext dsl;
2927

3028
Author author = Author.AUTHOR;
3129
Book book = Book.BOOK;
3230
AuthorBook authorBook = AuthorBook.AUTHOR_BOOK;
3331

3432
@Test
3533
public void givenValidData_whenInserting_thenSucceed() {
36-
create.insertInto(author).set(author.ID, 4).set(author.FIRST_NAME, "Herbert").set(author.LAST_NAME, "Schildt").execute();
37-
create.insertInto(book).set(book.ID, 4).set(book.TITLE, "A Beginner's Guide").execute();
38-
create.insertInto(authorBook).set(authorBook.AUTHOR_ID, 4).set(authorBook.BOOK_ID, 4).execute();
39-
Result<Record3<Integer, String, Integer>> result = create.select(author.ID, author.LAST_NAME, DSL.count()).from(author).join(authorBook).on(author.ID.equal(authorBook.AUTHOR_ID)).join(book).on(authorBook.BOOK_ID.equal(book.ID))
34+
dsl.insertInto(author).set(author.ID, 4).set(author.FIRST_NAME, "Herbert").set(author.LAST_NAME, "Schildt").execute();
35+
dsl.insertInto(book).set(book.ID, 4).set(book.TITLE, "A Beginner's Guide").execute();
36+
dsl.insertInto(authorBook).set(authorBook.AUTHOR_ID, 4).set(authorBook.BOOK_ID, 4).execute();
37+
Result<Record3<Integer, String, Integer>> result = dsl.select(author.ID, author.LAST_NAME, DSL.count()).from(author).join(authorBook).on(author.ID.equal(authorBook.AUTHOR_ID)).join(book).on(authorBook.BOOK_ID.equal(book.ID))
4038
.groupBy(author.LAST_NAME).fetch();
4139

4240
assertEquals(3, result.size());
@@ -48,15 +46,15 @@ public void givenValidData_whenInserting_thenSucceed() {
4846

4947
@Test(expected = DataAccessException.class)
5048
public void givenInvalidData_whenInserting_thenFail() {
51-
create.insertInto(authorBook).set(authorBook.AUTHOR_ID, 4).set(authorBook.BOOK_ID, 5).execute();
49+
dsl.insertInto(authorBook).set(authorBook.AUTHOR_ID, 4).set(authorBook.BOOK_ID, 5).execute();
5250
}
5351

5452
@Test
5553
public void givenValidData_whenUpdating_thenSucceed() {
56-
create.update(author).set(author.LAST_NAME, "Baeldung").where(author.ID.equal(3)).execute();
57-
create.update(book).set(book.TITLE, "Building your REST API with Spring").where(book.ID.equal(3)).execute();
58-
create.insertInto(authorBook).set(authorBook.AUTHOR_ID, 3).set(authorBook.BOOK_ID, 3).execute();
59-
Result<Record3<Integer, String, String>> result = create.select(author.ID, author.LAST_NAME, book.TITLE).from(author).join(authorBook).on(author.ID.equal(authorBook.AUTHOR_ID)).join(book).on(authorBook.BOOK_ID.equal(book.ID)).where(author.ID.equal(3))
54+
dsl.update(author).set(author.LAST_NAME, "Baeldung").where(author.ID.equal(3)).execute();
55+
dsl.update(book).set(book.TITLE, "Building your REST API with Spring").where(book.ID.equal(3)).execute();
56+
dsl.insertInto(authorBook).set(authorBook.AUTHOR_ID, 3).set(authorBook.BOOK_ID, 3).execute();
57+
Result<Record3<Integer, String, String>> result = dsl.select(author.ID, author.LAST_NAME, book.TITLE).from(author).join(authorBook).on(author.ID.equal(authorBook.AUTHOR_ID)).join(book).on(authorBook.BOOK_ID.equal(book.ID)).where(author.ID.equal(3))
6058
.fetch();
6159

6260
assertEquals(1, result.size());
@@ -67,13 +65,13 @@ public void givenValidData_whenUpdating_thenSucceed() {
6765

6866
@Test(expected = DataAccessException.class)
6967
public void givenInvalidData_whenUpdating_thenFail() {
70-
create.update(authorBook).set(authorBook.AUTHOR_ID, 4).set(authorBook.BOOK_ID, 5).execute();
68+
dsl.update(authorBook).set(authorBook.AUTHOR_ID, 4).set(authorBook.BOOK_ID, 5).execute();
7169
}
7270

7371
@Test
7472
public void givenValidData_whenDeleting_thenSucceed() {
75-
create.delete(author).where(author.ID.lt(3)).execute();
76-
Result<Record3<Integer, String, String>> result = create.select(author.ID, author.FIRST_NAME, author.LAST_NAME).from(author).fetch();
73+
dsl.delete(author).where(author.ID.lt(3)).execute();
74+
Result<Record3<Integer, String, String>> result = dsl.select(author.ID, author.FIRST_NAME, author.LAST_NAME).from(author).fetch();
7775

7876
assertEquals(1, result.size());
7977
assertEquals("Bryan", result.getValue(0, author.FIRST_NAME));
@@ -82,6 +80,6 @@ public void givenValidData_whenDeleting_thenSucceed() {
8280

8381
@Test(expected = DataAccessException.class)
8482
public void givenInvalidData_whenDeleting_thenFail() {
85-
create.delete(book).where(book.ID.equal(1)).execute();
83+
dsl.delete(book).where(book.ID.equal(1)).execute();
8684
}
8785
}

‎spring-mvc-xml/.classpath‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

‎spring-mvc-xml/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎spring-mvc-xml/.project‎

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎spring-mvc-xml/.settings/.jsdtscope‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎spring-mvc-xml/.settings/org.eclipse.jdt.core.prefs‎

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)