diff --git a/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
new file mode 100644
index 0000000..0522c86
--- /dev/null
+++ b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
new file mode 100644
index 0000000..0522c86
--- /dev/null
+++ b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
new file mode 100644
index 0000000..dccab76
--- /dev/null
+++ b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
new file mode 100644
index 0000000..0522c86
--- /dev/null
+++ b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
new file mode 100644
index 0000000..dccab76
--- /dev/null
+++ b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
new file mode 100644
index 0000000..1a91ac2
--- /dev/null
+++ b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
new file mode 100644
index 0000000..0522c86
--- /dev/null
+++ b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
new file mode 100644
index 0000000..dccab76
--- /dev/null
+++ b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
new file mode 100644
index 0000000..1a91ac2
--- /dev/null
+++ b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/simple-database.iml b/.idea/modules/simple-database.iml
index bbfc613..3039881 100644
--- a/.idea/modules/simple-database.iml
+++ b/.idea/modules/simple-database.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
new file mode 100644
index 0000000..0522c86
--- /dev/null
+++ b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
new file mode 100644
index 0000000..dccab76
--- /dev/null
+++ b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
new file mode 100644
index 0000000..1a91ac2
--- /dev/null
+++ b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/simple-database.iml b/.idea/modules/simple-database.iml
index bbfc613..3039881 100644
--- a/.idea/modules/simple-database.iml
+++ b/.idea/modules/simple-database.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/build.gradle b/build.gradle
index 560feec..29eb3a3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
group 'nl.astraeus'
-version '2.0.2-SNAPSHOT'
+version '2.0.4-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
diff --git a/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
new file mode 100644
index 0000000..0522c86
--- /dev/null
+++ b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
new file mode 100644
index 0000000..dccab76
--- /dev/null
+++ b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
new file mode 100644
index 0000000..1a91ac2
--- /dev/null
+++ b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/simple-database.iml b/.idea/modules/simple-database.iml
index bbfc613..3039881 100644
--- a/.idea/modules/simple-database.iml
+++ b/.idea/modules/simple-database.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/build.gradle b/build.gradle
index 560feec..29eb3a3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
group 'nl.astraeus'
-version '2.0.2-SNAPSHOT'
+version '2.0.4-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
diff --git a/src/nl/astraeus/database/annotations/Column.java b/src/nl/astraeus/database/annotations/Column.java
index 0a5c1c6..7979477 100644
--- a/src/nl/astraeus/database/annotations/Column.java
+++ b/src/nl/astraeus/database/annotations/Column.java
@@ -1,7 +1,9 @@
package nl.astraeus.database.annotations;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* User: rnentjes
@@ -9,6 +11,7 @@
* Time: 4:13 PM
*/
@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD } )
public @interface Column {
String name() default "";
diff --git a/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
new file mode 100644
index 0000000..0522c86
--- /dev/null
+++ b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
new file mode 100644
index 0000000..dccab76
--- /dev/null
+++ b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
new file mode 100644
index 0000000..1a91ac2
--- /dev/null
+++ b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/simple-database.iml b/.idea/modules/simple-database.iml
index bbfc613..3039881 100644
--- a/.idea/modules/simple-database.iml
+++ b/.idea/modules/simple-database.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/build.gradle b/build.gradle
index 560feec..29eb3a3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
group 'nl.astraeus'
-version '2.0.2-SNAPSHOT'
+version '2.0.4-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
diff --git a/src/nl/astraeus/database/annotations/Column.java b/src/nl/astraeus/database/annotations/Column.java
index 0a5c1c6..7979477 100644
--- a/src/nl/astraeus/database/annotations/Column.java
+++ b/src/nl/astraeus/database/annotations/Column.java
@@ -1,7 +1,9 @@
package nl.astraeus.database.annotations;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* User: rnentjes
@@ -9,6 +11,7 @@
* Time: 4:13 PM
*/
@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD } )
public @interface Column {
String name() default "";
diff --git a/src/nl/astraeus/database/annotations/Reference.java b/src/nl/astraeus/database/annotations/Reference.java
index 4daa49b..85ea834 100644
--- a/src/nl/astraeus/database/annotations/Reference.java
+++ b/src/nl/astraeus/database/annotations/Reference.java
@@ -1,7 +1,9 @@
package nl.astraeus.database.annotations;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* User: rnentjes
@@ -9,6 +11,7 @@
* Time: 4:13 PM
*/
@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD } )
public @interface Reference {
int length() default 12;
diff --git a/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
new file mode 100644
index 0000000..0522c86
--- /dev/null
+++ b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
new file mode 100644
index 0000000..dccab76
--- /dev/null
+++ b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
new file mode 100644
index 0000000..1a91ac2
--- /dev/null
+++ b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/simple-database.iml b/.idea/modules/simple-database.iml
index bbfc613..3039881 100644
--- a/.idea/modules/simple-database.iml
+++ b/.idea/modules/simple-database.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/build.gradle b/build.gradle
index 560feec..29eb3a3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
group 'nl.astraeus'
-version '2.0.2-SNAPSHOT'
+version '2.0.4-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
diff --git a/src/nl/astraeus/database/annotations/Column.java b/src/nl/astraeus/database/annotations/Column.java
index 0a5c1c6..7979477 100644
--- a/src/nl/astraeus/database/annotations/Column.java
+++ b/src/nl/astraeus/database/annotations/Column.java
@@ -1,7 +1,9 @@
package nl.astraeus.database.annotations;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* User: rnentjes
@@ -9,6 +11,7 @@
* Time: 4:13 PM
*/
@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD } )
public @interface Column {
String name() default "";
diff --git a/src/nl/astraeus/database/annotations/Reference.java b/src/nl/astraeus/database/annotations/Reference.java
index 4daa49b..85ea834 100644
--- a/src/nl/astraeus/database/annotations/Reference.java
+++ b/src/nl/astraeus/database/annotations/Reference.java
@@ -1,7 +1,9 @@
package nl.astraeus.database.annotations;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* User: rnentjes
@@ -9,6 +11,7 @@
* Time: 4:13 PM
*/
@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD } )
public @interface Reference {
int length() default 12;
diff --git a/test/nl/astraeus/database/BaseTest.java b/test/nl/astraeus/database/BaseTest.java
index 61ba8d7..bbdee04 100644
--- a/test/nl/astraeus/database/BaseTest.java
+++ b/test/nl/astraeus/database/BaseTest.java
@@ -35,9 +35,7 @@
connection.setAutoCommit(false);
return connection;
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException(e);
- } catch (SQLException e) {
+ } catch (ClassNotFoundException | SQLException e) {
throw new IllegalStateException(e);
}
}
diff --git a/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
new file mode 100644
index 0000000..0522c86
--- /dev/null
+++ b/.idea/libraries/Gradle__com_h2database_h2_1_4_193.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
new file mode 100644
index 0000000..dccab76
--- /dev/null
+++ b/.idea/libraries/Gradle__nl_astraeus_jdbc_simple_jdbc_stats_1_5_3.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
new file mode 100644
index 0000000..1a91ac2
--- /dev/null
+++ b/.idea/libraries/Gradle__org_slf4j_slf4j_simple_1_7_21.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/simple-database.iml b/.idea/modules/simple-database.iml
index bbfc613..3039881 100644
--- a/.idea/modules/simple-database.iml
+++ b/.idea/modules/simple-database.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/build.gradle b/build.gradle
index 560feec..29eb3a3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
group 'nl.astraeus'
-version '2.0.2-SNAPSHOT'
+version '2.0.4-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
diff --git a/src/nl/astraeus/database/annotations/Column.java b/src/nl/astraeus/database/annotations/Column.java
index 0a5c1c6..7979477 100644
--- a/src/nl/astraeus/database/annotations/Column.java
+++ b/src/nl/astraeus/database/annotations/Column.java
@@ -1,7 +1,9 @@
package nl.astraeus.database.annotations;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* User: rnentjes
@@ -9,6 +11,7 @@
* Time: 4:13 PM
*/
@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD } )
public @interface Column {
String name() default "";
diff --git a/src/nl/astraeus/database/annotations/Reference.java b/src/nl/astraeus/database/annotations/Reference.java
index 4daa49b..85ea834 100644
--- a/src/nl/astraeus/database/annotations/Reference.java
+++ b/src/nl/astraeus/database/annotations/Reference.java
@@ -1,7 +1,9 @@
package nl.astraeus.database.annotations;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
* User: rnentjes
@@ -9,6 +11,7 @@
* Time: 4:13 PM
*/
@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD } )
public @interface Reference {
int length() default 12;
diff --git a/test/nl/astraeus/database/BaseTest.java b/test/nl/astraeus/database/BaseTest.java
index 61ba8d7..bbdee04 100644
--- a/test/nl/astraeus/database/BaseTest.java
+++ b/test/nl/astraeus/database/BaseTest.java
@@ -35,9 +35,7 @@
connection.setAutoCommit(false);
return connection;
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException(e);
- } catch (SQLException e) {
+ } catch (ClassNotFoundException | SQLException e) {
throw new IllegalStateException(e);
}
}
diff --git a/test/nl/astraeus/database/TestMultipleDatabase.java b/test/nl/astraeus/database/TestMultipleDatabase.java
new file mode 100644
index 0000000..843a32e
--- /dev/null
+++ b/test/nl/astraeus/database/TestMultipleDatabase.java
@@ -0,0 +1,98 @@
+package nl.astraeus.database;
+
+import nl.astraeus.database.jdbc.ConnectionPool;
+import nl.astraeus.database.jdbc.ConnectionProvider;
+import nl.astraeus.database.test.model.Person;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * Date: 11/16/13
+ * Time: 12:27 AM
+ */
+public class TestMultipleDatabase {
+
+ private static SimpleDatabase first;
+ private static SimpleDatabase second;
+
+ @BeforeClass
+ public static void createDatabase() {
+ first = SimpleDatabase.define("first", new ConnectionPool(new ConnectionProvider() {
+ @Override
+ public Connection getConnection() {
+ try {
+ Class.forName("org.h2.Driver");
+
+ Connection connection = DriverManager.getConnection("jdbc:h2:mem:TestFirst", "sa", "");
+ connection.setAutoCommit(false);
+
+ return connection;
+ } catch (ClassNotFoundException | SQLException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }));
+
+ second = SimpleDatabase.define("second", new ConnectionPool(new ConnectionProvider() {
+ @Override
+ public Connection getConnection() {
+ try {
+ Class.forName("org.h2.Driver");
+
+ Connection connection = DriverManager.getConnection("jdbc:h2:mem:TestSecond", "sa", "");
+ connection.setAutoCommit(false);
+
+ return connection;
+ } catch (ClassNotFoundException | SQLException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }));
+
+ first.setExecuteDDLUpdates(true);
+ second.setExecuteDDLUpdates(true);
+ }
+
+ @Test
+ public void testUpdate() {
+ SimpleDao firstDao = new SimpleDao(Person.class, "first");
+ SimpleDao secondDao = new SimpleDao(Person.class, "second");
+
+ firstDao.execute(new SimpleDao.Executor() {
+ @Override
+ public void execute(SimpleDao dao) {
+ dao.insert(new Person("Jan", 32, "Straat"));
+ dao.insert(new Person("Ronald", 31, "Wherever"));
+ dao.insert(new Person("Piet", 26, "Weg"));
+ dao.insert(new Person("Klaas", 10, "Pad"));
+ }
+ });
+
+ List persons = firstDao.where("age > ?", 30);
+
+ first.begin();
+
+ for (Person person : persons) {
+ person.setAge(person.getAge() + 1);
+
+ firstDao.update(person);
+ }
+
+ first.commit();
+
+ persons = firstDao.where("age > ?", 32);
+
+ Assert.assertEquals(persons.size(), 2);
+
+ persons = secondDao.where("age > ?", 32);
+
+ Assert.assertEquals(persons.size(), 0);
+ }
+
+}