I have an entity with 4 fields, for example:
@Preload interface SomeEntity extends Entity { @NotNull String getProperty1(); void setPropery1(String value); @NotNull String getProperty2(); void setPropery2(String value); @NotNull String getProperty3(); void setPropery3(String value); @NotNull String getProperty4(); void setPropery4(String value); }
And I know, that users will mostly query for entity using first 3 fields with a query like:
Query.select().where("property1 = ? AND property2 = ? AND property3 = ?", property1, property2, property3);
If I add @Index annotation to all fields, it will create 4 idexes for each of field, and this will be not effective for query. Is there any way to create multicolumn index in Active Objects?
Community moderators have prevented the ability to post new answers.
Hi,
as far as I know this is not possible with AO at the moment: https://ecosystem.atlassian.net/browse/AO-96.
The capabilities of the library are still quite limited.
Regards
Theresa
This issue does not exist.
Anyway, are there any chances, that if I create this index manually, AO will not delete it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sry, the URL was with a dot behind it, so it didn't work, this one exists:
https://ecosystem.atlassian.net/browse/AO-96
I am actually curious too if manually creating an index on AO tables would work. Add the AO logger: net.java.ao.sql and check what AO actually does on plugin deployment or when starting/stoping an instance.
I am not sure, but if I remember correctly, the tables will be updated and indexes newly created on every plugin update. You could also recreate your index new on every plugin update, too.
If you try this, I would be happy to hear about your steps and the results.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Update: Since Version 1.2 of Active Objects this should be possible:
import net.java.ao.Entity; import net.java.ao.schema.Index; import net.java.ao.schema.Indexes; @Indexes({ @Index(name = "names", methodNames = {"getFirstName", "getLastName"}), @Index(name = "age", methodNames = "getAge") }) public interface Person extends Entity { public String getFirstName(); public void setFirstName(String firstName); public void setLastName(String lastName); public String getLastName(); public int getAge(); public void setAge(int age); }
Source: Active Objects 1.2.0 Upgrade guide
I have yet to try it, though ... ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have tried putting this entity but still not getting index reflected in Database.
My activeobjects version is 1.2. Please let me know if you are able to get Index reflected in DB for multiple columns using @Indexed annotation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's been some time ago, but i think i did not try it back then, so i cannot confirm that it really works. As stated in the answer, the info is from the AO upgrade notes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.