Skip to content

Commit 733cdae

Browse files
committed
adjust setting query param to also use entity ID
1 parent 69342cf commit 733cdae

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

objectbox-java/src/main/java/io/objectbox/Property.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ public QueryCondition endsWith(String value) {
140140
return new PropertyCondition(this, Operation.ENDS_WITH, value);
141141
}
142142

143+
@Internal
144+
public int getEntityId() {
145+
return entity.getEntityId();
146+
}
147+
143148
@Internal
144149
public int getId() {
145150
if (this.id <= 0) {

objectbox-java/src/main/java/io/objectbox/query/Query.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,20 @@ native String nativeFindString(long handle, long cursorHandle, int propertyId, b
107107

108108
native long nativeRemove(long handle, long cursorHandle);
109109

110-
native void nativeSetParameter(long handle, int propertyId, @Nullable String parameterAlias, String value);
110+
native void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable String parameterAlias,
111+
String value);
111112

112-
native void nativeSetParameter(long handle, int propertyId, @Nullable String parameterAlias, long value);
113+
native void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable String parameterAlias,
114+
long value);
113115

114-
native void nativeSetParameters(long handle, int propertyId, @Nullable String parameterAlias, long value1,
115-
long value2);
116+
native void nativeSetParameters(long handle, int entityId, int propertyId, @Nullable String parameterAlias,
117+
long value1, long value2);
116118

117-
native void nativeSetParameter(long handle, int propertyId, @Nullable String parameterAlias, double value);
119+
native void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable String parameterAlias,
120+
double value);
118121

119-
native void nativeSetParameters(long handle, int propertyId, @Nullable String parameterAlias, double value1,
120-
double value2);
122+
native void nativeSetParameters(long handle, int entityId, int propertyId, @Nullable String parameterAlias,
123+
double value1, double value2);
121124

122125
final Box<T> box;
123126
private final BoxStore store;
@@ -455,50 +458,53 @@ public double avg(final Property property) {
455458
* Sets a parameter previously given to the {@link QueryBuilder} to a new value.
456459
*/
457460
public Query<T> setParameter(Property property, String value) {
458-
nativeSetParameter(handle, property.getId(), null, value);
461+
nativeSetParameter(handle, property.getEntityId(), property.getId(), null, value);
459462
return this;
460463
}
461464

462465
/**
463466
* Sets a parameter previously given to the {@link QueryBuilder} to a new value.
467+
*
464468
* @param alias as defined using {@link QueryBuilder#parameterAlias(String)}.
465469
*/
466470
public Query<T> setParameter(String alias, String value) {
467-
nativeSetParameter(handle, 0, alias, value);
471+
nativeSetParameter(handle, 0, 0, alias, value);
468472
return this;
469473
}
470474

471475
/**
472476
* Sets a parameter previously given to the {@link QueryBuilder} to a new value.
473477
*/
474478
public Query<T> setParameter(Property property, long value) {
475-
nativeSetParameter(handle, property.getId(), null, value);
479+
nativeSetParameter(handle, property.getEntityId(), property.getId(), null, value);
476480
return this;
477481
}
478482

479483
/**
480484
* Sets a parameter previously given to the {@link QueryBuilder} to a new value.
485+
*
481486
* @param alias as defined using {@link QueryBuilder#parameterAlias(String)}.
482487
*/
483488
public Query<T> setParameter(String alias, long value) {
484-
nativeSetParameter(handle, 0, alias, value);
489+
nativeSetParameter(handle, 0, 0, alias, value);
485490
return this;
486491
}
487492

488493
/**
489494
* Sets a parameter previously given to the {@link QueryBuilder} to a new value.
490495
*/
491496
public Query<T> setParameter(Property property, double value) {
492-
nativeSetParameter(handle, property.getId(), null, value);
497+
nativeSetParameter(handle, property.getEntityId(), property.getId(), null, value);
493498
return this;
494499
}
495500

496501
/**
497502
* Sets a parameter previously given to the {@link QueryBuilder} to a new value.
503+
*
498504
* @param alias as defined using {@link QueryBuilder#parameterAlias(String)}.
499505
*/
500506
public Query<T> setParameter(String alias, double value) {
501-
nativeSetParameter(handle, 0, alias, value);
507+
nativeSetParameter(handle, 0, 0, alias, value);
502508
return this;
503509
}
504510

@@ -513,8 +519,8 @@ public Query<T> setParameter(Property property, Date value) {
513519

514520
/**
515521
* Sets a parameter previously given to the {@link QueryBuilder} to a new value.
516-
* @param alias as defined using {@link QueryBuilder#parameterAlias(String)}.
517522
*
523+
* @param alias as defined using {@link QueryBuilder#parameterAlias(String)}.
518524
* @throws NullPointerException if given date is null
519525
*/
520526
public Query<T> setParameter(String alias, Date value) {
@@ -530,6 +536,7 @@ public Query<T> setParameter(Property property, boolean value) {
530536

531537
/**
532538
* Sets a parameter previously given to the {@link QueryBuilder} to a new value.
539+
*
533540
* @param alias as defined using {@link QueryBuilder#parameterAlias(String)}.
534541
*/
535542
public Query<T> setParameter(String alias, boolean value) {
@@ -540,33 +547,35 @@ public Query<T> setParameter(String alias, boolean value) {
540547
* Sets a parameter previously given to the {@link QueryBuilder} to new values.
541548
*/
542549
public Query<T> setParameters(Property property, long value1, long value2) {
543-
nativeSetParameters(handle, property.getId(), null, value1, value2);
550+
nativeSetParameters(handle, property.getEntityId(), property.getId(), null, value1, value2);
544551
return this;
545552
}
546553

547554
/**
548555
* Sets a parameter previously given to the {@link QueryBuilder} to new values.
556+
*
549557
* @param alias as defined using {@link QueryBuilder#parameterAlias(String)}.
550558
*/
551559
public Query<T> setParameters(String alias, long value1, long value2) {
552-
nativeSetParameters(handle, 0, alias, value1, value2);
560+
nativeSetParameters(handle, 0, 0, alias, value1, value2);
553561
return this;
554562
}
555563

556564
/**
557565
* Sets a parameter previously given to the {@link QueryBuilder} to new values.
558566
*/
559567
public Query<T> setParameters(Property property, double value1, double value2) {
560-
nativeSetParameters(handle, property.getId(), null, value1, value2);
568+
nativeSetParameters(handle, property.getEntityId(), property.getId(), null, value1, value2);
561569
return this;
562570
}
563571

564572
/**
565573
* Sets a parameter previously given to the {@link QueryBuilder} to new values.
574+
*
566575
* @param alias as defined using {@link QueryBuilder#parameterAlias(String)}.
567576
*/
568577
public Query<T> setParameters(String alias, double value1, double value2) {
569-
nativeSetParameters(handle, 0, alias, value1, value2);
578+
nativeSetParameters(handle, 0, 0, alias, value1, value2);
570579
return this;
571580
}
572581

0 commit comments

Comments
 (0)