File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
src/main/java/org/javawebstack/orm Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ public class Model {
4141 private transient boolean internalEntryExists = false ;
4242 private transient final Map <Class <? extends Model >, Object > internalJoinedModels = new HashMap <>();
4343 private transient Map <String , Object > internalOriginalValues = new HashMap <>();
44+ private transient Map <String , Object > internalExtraFields = new HashMap <>();
4445
4546 void internalAddJoinedModel (Class <? extends Model > type , Object entity ) {
4647 internalJoinedModels .put (type , entity );
@@ -62,6 +63,14 @@ public Map<String, Object> getFieldValues() {
6263 return values ;
6364 }
6465
66+ public Map <String , Object > getExtraFields () {
67+ return internalExtraFields ;
68+ }
69+
70+ public <T > T getExtraField (String key ) {
71+ return (T ) internalExtraFields .get (key );
72+ }
73+
6574 public Map <String , Object > getOriginalValues () {
6675 return internalOriginalValues ;
6776 }
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ public class Query<T extends Model> {
2727 private QueryColumn order ;
2828 private boolean desc = false ;
2929 private boolean withDeleted = false ;
30+ private final List <QueryWith > withs = new ArrayList <>();
3031
3132 public Query (Class <T > model ) {
3233 this (Repo .get (model ), model );
@@ -46,6 +47,10 @@ public QueryGroup<T> getWhereGroup() {
4647 return where ;
4748 }
4849
50+ public List <QueryWith > getWiths () {
51+ return withs ;
52+ }
53+
4954 public Integer getLimit () {
5055 return limit ;
5156 }
@@ -70,6 +75,15 @@ public Class<T> getModel() {
7075 return model ;
7176 }
7277
78+ public Query <T > with (String extra ) {
79+ return with (extra , null );
80+ }
81+
82+ public Query <T > with (String extra , String as ) {
83+ withs .add (new QueryWith (extra , as ));
84+ return this ;
85+ }
86+
7387 public Query <T > and (Function <QueryGroup <T >, QueryGroup <T >> group ) {
7488 where .and (group );
7589 return this ;
Original file line number Diff line number Diff line change 1+ package org .javawebstack .orm .query ;
2+
3+ public class QueryWith {
4+
5+ private final String expression ;
6+ private final String as ;
7+
8+ public QueryWith (String expression , String as ) {
9+ this .expression = expression ;
10+ this .as = as ;
11+ }
12+
13+ public String getExpression () {
14+ return expression ;
15+ }
16+
17+ public String getAs () {
18+ return as ;
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments