Skip to content

Commit c5c1424

Browse files
Tests: update docs on relation test classes
1 parent b5e4d99 commit c5c1424

File tree

7 files changed

+41
-23
lines changed

7 files changed

+41
-23
lines changed

tests/objectbox-java-test/src/main/java/io/objectbox/relation/Customer.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,10 +24,15 @@
2424
import io.objectbox.annotation.Entity;
2525
import io.objectbox.annotation.Id;
2626
import io.objectbox.annotation.Index;
27-
import io.objectbox.annotation.apihint.Internal;
2827

2928
/**
30-
* Entity mapped to table "CUSTOMER".
29+
* Customer entity to test relations together with {@link Order}.
30+
* <p>
31+
* The annotations in this class have no effect as the Gradle plugin is not configured in this project. However, test
32+
* code builds a model like if the annotations were processed.
33+
* <p>
34+
* There is a matching test in the internal integration test project where this is tested and model builder code can be
35+
* "stolen" from.
3136
*/
3237
@Entity
3338
public class Customer implements Serializable {
@@ -38,12 +43,16 @@ public class Customer implements Serializable {
3843
@Index
3944
private String name;
4045

41-
@Backlink(to = "customer") // Annotation not processed in this test, is set up manually.
46+
// Note: in a typical project the relation fields are initialized by the ObjectBox byte code transformer
47+
// https://docs.objectbox.io/relations#initialization-magic
48+
49+
@Backlink(to = "customer")
4250
List<Order> orders = new ToMany<>(this, Customer_.orders);
4351

4452
ToMany<Order> ordersStandalone = new ToMany<>(this, Customer_.ordersStandalone);
4553

46-
/** Used to resolve relations. */
54+
// Note: in a typical project the BoxStore field is added by the ObjectBox byte code transformer
55+
// https://docs.objectbox.io/relations#initialization-magic
4756
transient BoxStore __boxStore;
4857

4958
public Customer() {

tests/objectbox-java-test/src/main/java/io/objectbox/relation/CustomerCursor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,8 @@
2222
import io.objectbox.Transaction;
2323
import io.objectbox.internal.CursorFactory;
2424

25-
// THIS CODE IS ADAPTED from generated resources of the test-entity-annotations project
25+
// NOTE: Instead of updating this by hand, copy changes from the internal integration test project after updating its
26+
// Customer class.
2627

2728
/**
2829
* Cursor for DB entity "Customer".

tests/objectbox-java-test/src/main/java/io/objectbox/relation/Customer_.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*
3-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
43
*
54
* Licensed under the Apache License, Version 2.0 (the "License");
65
* you may not use this file except in compliance with the License.
@@ -28,7 +27,8 @@
2827
import io.objectbox.internal.ToOneGetter;
2928
import io.objectbox.relation.CustomerCursor.Factory;
3029

31-
// THIS CODE IS ADAPTED from generated resources of the test-entity-annotations project
30+
// NOTE: Instead of updating this by hand, copy changes from the internal integration test project after updating its
31+
// Customer class.
3232

3333
/**
3434
* Properties for entity "Customer". Can be used for QueryBuilder and for referencing DB names.

tests/objectbox-java-test/src/main/java/io/objectbox/relation/MyObjectBox.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,8 +23,9 @@
2323
import io.objectbox.model.PropertyFlags;
2424
import io.objectbox.model.PropertyType;
2525

26+
// NOTE: Instead of updating this by hand, copy changes from the internal integration test project after updating its
27+
// Customer class.
2628

27-
// THIS CODE IS ADAPTED from generated resources of the test-entity-annotations project
2829
/**
2930
* Starting point for working with your ObjectBox. All boxes are set up for your objects here.
3031
* <p>

tests/objectbox-java-test/src/main/java/io/objectbox/relation/Order.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,16 +18,19 @@
1818

1919
import java.io.Serializable;
2020

21-
import javax.annotation.Nullable;
22-
2321
import io.objectbox.BoxStore;
2422
import io.objectbox.annotation.Entity;
2523
import io.objectbox.annotation.Id;
2624
import io.objectbox.annotation.NameInDb;
27-
import io.objectbox.annotation.apihint.Internal;
2825

2926
/**
30-
* Entity mapped to table "ORDERS".
27+
* Order entity to test relations together with {@link Customer}.
28+
* <p>
29+
* The annotations in this class have no effect as the Gradle plugin is not configured in this project. However, test
30+
* code builds a model like if the annotations were processed.
31+
* <p>
32+
* There is a matching test in the internal integration test project where this is tested and model builder code can be
33+
* "stolen" from.
3134
*/
3235
@Entity
3336
@NameInDb("ORDERS")
@@ -39,10 +42,13 @@ public class Order implements Serializable {
3942
long customerId;
4043
String text;
4144

45+
// Note: in a typical project the relation fields are initialized by the ObjectBox byte code transformer
46+
// https://docs.objectbox.io/relations#initialization-magic
4247
@SuppressWarnings("FieldMayBeFinal")
4348
private ToOne<Customer> customer = new ToOne<>(this, Order_.customer);
4449

45-
/** Used to resolve relations. */
50+
// Note: in a typical project the BoxStore field is added by the ObjectBox byte code transformer
51+
// https://docs.objectbox.io/relations#initialization-magic
4652
transient BoxStore __boxStore;
4753

4854
public Order() {

tests/objectbox-java-test/src/main/java/io/objectbox/relation/OrderCursor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,11 +18,11 @@
1818

1919
import io.objectbox.BoxStore;
2020
import io.objectbox.Cursor;
21-
import io.objectbox.EntityInfo;
2221
import io.objectbox.Transaction;
2322
import io.objectbox.internal.CursorFactory;
2423

25-
// THIS CODE IS ADAPTED from generated resources of the test-entity-annotations project
24+
// NOTE: Instead of updating this by hand, copy changes from the internal integration test project after updating its
25+
// Customer class.
2626

2727
/**
2828
* Cursor for DB entity "ORDERS".

tests/objectbox-java-test/src/main/java/io/objectbox/relation/Order_.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
3+
* Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -25,7 +25,8 @@
2525
import io.objectbox.internal.ToOneGetter;
2626
import io.objectbox.relation.OrderCursor.Factory;
2727

28-
// THIS CODE IS ADAPTED from generated resources of the test-entity-annotations project
28+
// NOTE: Instead of updating this by hand, copy changes from the internal integration test project after updating its
29+
// Customer class.
2930

3031
/**
3132
* Properties for entity "ORDERS". Can be used for QueryBuilder and for referencing DB names.

0 commit comments

Comments
 (0)