Skip to content

Commit 6b74c00

Browse files
committed
Revert "#1394 Implement Model.findByIn() method"
This reverts commit b44bcef.
1 parent b44bcef commit 6b74c00

File tree

3 files changed

+46
-89
lines changed

3 files changed

+46
-89
lines changed

activejdbc/src/main/java/org/javalite/activejdbc/Model.java

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ private <T extends Model> T setRaw(String attributeName, Object value) {
393393
* (Instance state differs from state in DB)
394394
* @return true if this instance was modified.
395395
*/
396-
396+
397397
public boolean isModified() {
398398
return !dirtyAttributeNames.isEmpty();
399399
}
@@ -439,7 +439,7 @@ public static List<Association> associations() {
439439
*
440440
* @return true if this is a new instance, not saved yet to DB, false otherwise
441441
*/
442-
442+
443443
public boolean isNew(){
444444
return getId() == null && !compositeKeyPersisted;
445445
}
@@ -2204,7 +2204,7 @@ public static void callbackWith(CallbackListener... listeners) {
22042204
*
22052205
* @return true if no errors were generated, otherwise returns false.
22062206
*/
2207-
2207+
22082208
public boolean isValid(){
22092209
validate();
22102210
return !hasErrors();
@@ -2338,32 +2338,10 @@ public static <T extends Model> T createIt(Object ... namesAndValues){
23382338
return ModelDelegate.createIt(Model.<T>modelClass(), namesAndValues);
23392339
}
23402340

2341-
/**
2342-
* Finds ain instance of a model by ID.
2343-
* @param id value to look for
2344-
* @return instance of a model or null if nothing found
2345-
*/
23462341
public static <T extends Model> T findById(Object id) {
23472342
return ModelDelegate.findById(Model.<T>modelClass(), id);
23482343
}
23492344

2350-
/**
2351-
* Searches for records by a collection of values in a column. This is a workaround for queries using an IN list:
2352-
* <code>select * from users where first_name in ('John', 'Jodi')</code>.
2353-
* Example of usage:
2354-
* <pre>
2355-
* List&lt;Person&gt; people = Person.findByColumnIn("id", li(1, 2)).orderBy("id");
2356-
*</pre>
2357-
* In the code above the search is happening by column "id" for values matching 1 or 2.
2358-
* The <code>orderBy(...)</code> is optional (same for any other methods of a <code>LazyList</code>).
2359-
*
2360-
* @param column name of column of interest.
2361-
* @param values number of matching values for this column.
2362-
* @return a number or matching objects.
2363-
*/
2364-
public static <T extends Model> LazyList<T> findByColumnIn(String column, Collection<?> values) {
2365-
return ModelDelegate.findByColumnIn(Model.<T>modelClass(), column, values);
2366-
}
23672345
/**
23682346
* Composite PK values in exactly the same order as specified in {@link CompositePK}.
23692347
*
@@ -2959,7 +2937,7 @@ public static String getTableName() {
29592937
*
29602938
* @return of ID.
29612939
*/
2962-
2940+
29632941
public Object getId() {
29642942
return get(getIdName());
29652943
}
@@ -2969,7 +2947,7 @@ public Object getId() {
29692947
*
29702948
* @return Name of ID column.
29712949
*/
2972-
2950+
29732951
public String getIdName() {
29742952
return metaModelLocal.getIdName();
29752953
}
@@ -2979,7 +2957,7 @@ public String getIdName() {
29792957
*
29802958
* @return a list of composite keys as specified in {@link CompositePK}.
29812959
*/
2982-
2960+
29832961
public String[] getCompositeKeys() {
29842962
return metaModelLocal.getCompositeKeys();
29852963
}
@@ -3111,7 +3089,7 @@ public static void purgeCache() {
31113089
*
31123090
* @return value of attribute corresponding to <code>getIdName()</code>, converted to a Long.
31133091
*/
3114-
3092+
31153093
public Long getLongId() {
31163094
return getId() == null ? null: Convert.toLong(getId());
31173095
}

activejdbc/src/main/java/org/javalite/activejdbc/ModelDelegate.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
import java.text.DateFormat;
3737
import java.util.*;
3838

39-
import static org.javalite.common.Util.*;
39+
import static org.javalite.common.Util.blank;
40+
import static org.javalite.common.Util.empty;
4041

4142
/**
4243
* This class exists to offload some logic from {@link Model} class.
@@ -384,12 +385,6 @@ public static ValidationBuilder validateWith(Class<? extends Model> clazz, Valid
384385
return modelRegistryOf(clazz).validateWith(validator);
385386
}
386387

387-
public static <T extends Model> LazyList<T> findByColumnIn(Class<T> clazz, String column, Collection<?> values) {
388-
return empty(values) ?
389-
new LazyList<>() :
390-
new LazyList<>(" %s IN (%s)".formatted(column, join(values, ", ")), metaModelOf(clazz));
391-
}
392-
393388
public static <T extends Model> LazyList<T> where(Class<T> clazz, String subquery, Object... params) {
394389
if (subquery.trim().equals("*")) {
395390
if (empty(params)) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy