Hi,
I have two entities with a many to many relation. First entity is Carrier and the second entity is Folder.
public interface Folder extends Entity {
// other methods
@ManyToMany(through = "getFolder", reverse = "getCarrier", value = CarrierToFolder.class)
Carrier[] getCarriers();
} public interface Carrier extends Entity {
// others methods
@ManyToMany(through = "getCarrier", reverse = "getFolder", value = CarrierToFolder.class)
public Folder[] getFolders();
}How is the correct way to recovery all carriers associated with a folder?
I'm trying with this:
@Override
public Folder getFolder(String folderName) {
try {
Folder[] folder = ao.find(Folder.class,
Query.select().where("FOLDER_NAME = ?", folderName ));
if (folder.length != 0) {
return folder[0];
} else {
log.error("The query has not results.");
return null;
}
} catch (Exception ex) {
log.error("Error on get folder: " + ex.getMessage());
}
return null;
}
But, folder[0].getCarriers() always return 01 element.
Thank you.