Skip to content

Commit b527ee2

Browse files
Add ModelSetup to unify setup codes
1 parent e916495 commit b527ee2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.javawebstack.orm.test.shared.setup;
2+
3+
import org.javawebstack.orm.Model;
4+
import org.javawebstack.orm.ORM;
5+
import org.javawebstack.orm.Repo;
6+
import org.javawebstack.orm.exception.ORMConfigurationException;
7+
import org.javawebstack.orm.test.shared.settings.MySQLConnectionContainer;
8+
9+
public class ModelSetup extends MySQLConnectionContainer {
10+
11+
public static <T extends Model> Repo<T> setUpModel(Class<T> clazz) {
12+
13+
// Converting to Runtime exception to avoid having to declare the thrown error which has no utility
14+
try {
15+
ORM.register(clazz, sql());
16+
} catch (ORMConfigurationException e) {
17+
throw new RuntimeException(e);
18+
}
19+
20+
return Repo.get(clazz);
21+
}
22+
}

0 commit comments

Comments
 (0)