JQL limit results @ManyToMany

Hello,

My JIRA plugin has two entities with many to many relation. First entity is Carrier and the second entity is Folder:

Folder entity:

public interface Folder extends Entity {
// other methods
@ManyToMany(through = "getFolder", reverse = "getCarrier", value = CarrierToFolder.class)
Carrier[] getCarriers();
}

Carrier entity:

public interface Carrier extends Entity {
// others methods
@ManyToMany(through = "getCarrier", reverse = "getFolder", value = CarrierToFolder.class)
public Folder[] getFolders();
}

Now, I am trying to recover a folder with this code:

Folder[] folder = ao.find(Folder.class,
Query.select().where("FOLDER_NAME = ?", folderName ));

The var folder return the folder correctly. But, when I try to get all carriers related, only 01 record is available in “folder[0].getCarriers();” and 04 carriers is available in my database and related with the condition. I try to use join, but the condition is the same.

What’s wrong? Any suggestions?

Thanks.

Problem solved. My through and reverse attributes was wrong. This is the correct:

public interface Folder extends Entity {
// other methods
@ManyToMany(through = "getCarrier", reverse = "getFolder", value = CarrierToFolder.class)
Carrier[] getCarriers();
}
public interface Carrier extends Entity {
// others methods
@ManyToMany(through = "getFolder", reverse = "getCarrier", value = CarrierToFolder.class)
public Folder[] getFolders();
}

Thanks.