Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how to use specific table from Active Objects in jira

Jyoti Kumari
Contributor
January 15, 2025

Hello Everyone,

 

I want to perform query on table named as "AO_81F455_PERSONAL_TOKEN",but it is always taking table named as "AO_F97F98_PERSONAL_TOKEN",when I am adding @table annotation then getting below error ,kindly help, how we can delete token of specific user through jira plugin.Please find the code snippet and error below-

error - 

 

com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: net.java.ao.ActiveObjectsException: Invalid entity, generated table name (AO_F97F98_AO_81_F455_PERSONAL_TOKEN) for 'ao.PersonalToken' is too long! It should be no longer than 30 chars.
package ao;
import net.java.ao.Entity;
import net.java.ao.Preload;
import net.java.ao.schema.Table;

@Table("AO_81F455_PERSONAL_TOKEN")
@Preload("*")
public interface PersonalToken extends Entity {
String getUserKey();
void setUserKey(String userKey);

}


public void deleteTokensForUser(ApplicationUser user) {
String userKey = user.getKey();
logger.debug("userKey:" + userKey);
if(userKey!=null){
ao.executeInTransaction(() -> {
PersonalToken[] tokens = ao.find(PersonalToken.class, Query.select().where("USER_KEY = ?", userKey));
logger.debug("tokens:"+tokens);
for (PersonalToken token : tokens) {
logger.debug("token:"+token);
ao.delete(token);
logger.info("Deleted token with ID :"+token.getID()+" for userKey :"+userKey);
}
return null;
});
}
}

Kindly help how we can achieve these in jira plugin.

Thanks and Regards,
Jyoti

1 answer

0 votes
Mirek
Community Champion
January 28, 2025

Hi @Jyoti Kumari 

It looks that you are using @Table("AO_81F455_PERSONAL_TOKEN") in your code, but it seems that it is ignoring this annotation and using the default naming convention, which leads to the longer table name issue that is a combination of both AO_F97F98 and AO_81F455_PERSONAL_TOKEN -> AO_F97F98_AO_81_F455_PERSONAL_TOKEN

That is for sure more characters than 30.. actually 35 if I count correctly

So use a shorter name or remove the prefix completely in the "@Table" then rebuild your plugin and see how it works :) 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.15
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events