|
1 | 1 | package org.javawebstack.orm; |
2 | 2 |
|
| 3 | +import org.javawebstack.orm.query.Query; |
3 | 4 | import org.javawebstack.orm.util.Helper; |
4 | 5 |
|
5 | 6 | import java.lang.reflect.Field; |
|
10 | 11 |
|
11 | 12 | public class Model { |
12 | 13 |
|
13 | | - private static Method saveMethod; |
14 | | - private static Method deleteMethod; |
15 | | - private static Method finalDeleteMethod; |
16 | | - private static Method restoreMethod; |
17 | | - private static Method refreshMethod; |
| 14 | + private static final Method saveMethod; |
| 15 | + private static final Method deleteMethod; |
| 16 | + private static final Method finalDeleteMethod; |
| 17 | + private static final Method restoreMethod; |
| 18 | + private static final Method refreshMethod; |
18 | 19 |
|
19 | 20 | static { |
20 | 21 | try { |
@@ -42,6 +43,7 @@ public void save(){ |
42 | 43 | try { |
43 | 44 | saveMethod.invoke(ORM.repo(getClass()), this); |
44 | 45 | } catch (IllegalAccessException | InvocationTargetException e) { |
| 46 | + e.printStackTrace(); |
45 | 47 | throw new RuntimeException(e); |
46 | 48 | } |
47 | 49 | } |
@@ -120,11 +122,11 @@ public <T extends Model> List<T> hasMany(Class<T> child, String fieldName){ |
120 | 122 | return hasManyRelation(child, fieldName).all(); |
121 | 123 | } |
122 | 124 |
|
123 | | - public <T extends Model> QueryBuilder<T> hasManyRelation(Class<T> child){ |
| 125 | + public <T extends Model> Query<T> hasManyRelation(Class<T> child){ |
124 | 126 | return hasManyRelation(child, Helper.pascalToCamelCase(getClass().getSimpleName())+"Id"); |
125 | 127 | } |
126 | 128 |
|
127 | | - public <T extends Model> QueryBuilder<T> hasManyRelation(Class<T> child, String fieldName){ |
| 129 | + public <T extends Model> Query<T> hasManyRelation(Class<T> child, String fieldName){ |
128 | 130 | try { |
129 | 131 | Repo<?> ownRepo = Repo.get(getClass()); |
130 | 132 | Integer id = (Integer) ownRepo.getInfo().getField(ownRepo.getInfo().getIdField()).get(this); |
|
0 commit comments