JIRA 6.1: OfBizDelegator does not search by key

I am a developer of JIRA plugin: https://marketplace.atlassian.com/plugins/com.romexsoft.worklogcal.jira-worklogcal
And there I have a code that performs search with com.atlassian.jira.ofbiz.OfBizDelegator by issue key. The code started to work incorrectly in JIRA 6.1 - 6.1.4. It returns empty list of issues when some issues are expected.
When I comment the EntityExpr for the key, list of issues is returned but all they have key field as null. Interesting is that when I iterate through the issues and invoke gi.getString("key"); I get the correct issue key.

List<EntityCondition> exprs = new ArrayList<EntityCondition>();
exprs.add(new EntityExpr("key", EntityOperator.LIKE, issueKey.toUpperCase()));
exprs.add(new EntityExpr("project", EntityOperator.IN, projectIds));
exprs.add(new EntityExpr("status", EntityOperator.NOT_EQUAL, IssueFieldConstants.CLOSED_STATUS));
List<GenericValue> issues = ofBizDelegator.findByCondition("Issue", new EntityConditionList(exprs,
EntityOperator.AND), null, Arrays.asList("id"));
if (issues.size() > 0) {
for (GenericValue gi : issues) {
String test = gi.getString("key");
}
}

The problem appeared in JIRA v.1.6.1. So I assume that there were some changes in JIRA v.1.6.1 that caused the OfBizDelegator to work incorrectly.

Any help will be appreciated.

Thank you

1 answer

1 accepted

JIRA 6.1 included changes to how issue keys are stored in the DB in order to support the ability to edit project keys.

The details are in https://developer.atlassian.com/display/JIRADEV/Preparing+for+JIRA+6.1under the "Database changes for the Edit Project Key feature" section.

There was some code added to make the GenericValues be able to respond to getString("key") in a backward compatible way, but this obviously didn't extend to searching.

You are going to have to change your code to search on the projectId and the new "IssueNumber" column in JIRA 6.1 and higher.

Thank you!

For JIRA 6.1 and higher I adjuysted the code to search by number:

exprs.add(new EntityExpr("number", EntityOperator.LIKE, autocomplIssueNumb));

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

170 views 4 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you