Active Objects SqlException by getting data

Hi,

here are my Entity Interfaces:

@Preload
@Table("Category")
public interface CategoryEntity extends Entity {

    int getCategoryId();
    void setCategoryId(int categoryId);

    String getCategoryTitle();
    void setCategoryTitle(String categoryTitle);

    String getCategoryDescription();
    void setCategoryDescription(String categoryDescription);

    @OneToMany
    public SkillEntity[] getSkills();
}

and

@Preload
@Table("Skill")
public interface SkillEntity extends Entity {

    CategoryEntity getCategoryEntity();
    void setCategoryEntity(CategoryEntity category);

    int getSkillId();
    void setSkillId(int skillId);

    String getSkillTitle();
    void setSkillTitle(String skillTitle);

    String getSkillDescription();
    void setSkillDescription(String skillDescription);
}

and i'm trying to get all Skills for Category, by Category!

here is my SQL Query:

@Override
    public List<SkillEntity> fetchSkillsByCategory(CategoryEntity category) {
        try {
            return Lists.newArrayList(ao.find(SkillEntity.class, Query.select().where("CATEGORY_ENTITY = ?", category)));
        } catch (Exception exception){
            return Lists.newArrayList();
        }
    }

Exception is:

java.sql.SQLSyntaxErrorException: user lacks privilege not found: CATEGORY_ENTITY

please give advice, how to query db to get data back!!!

Thanks!!!

1 answer

1 accepted

You have annotated your Entity with @Table("Category") which changes the name of the table. To make your Query work, you have to remove the annotation or change it to @Table("CATEGORY_ENTITY").

Alternatively you could adjust the Query.

/EDIT: Didn't read the Question right. He should use category.getSkills(). See comments.

Please forgive me the stupid question :-) how can i adjust the Query to get it work?

i have changed my entity names to:

@Preload
@Table("CATEGORY")
public interface CategoryEntity extends Entity {

    int getCategoryId();
    void setCategoryId(int categoryId);

    String getCategoryTitle();
    void setCategoryTitle(String categoryTitle);

    String getCategoryDescription();
    void setCategoryDescription(String categoryDescription);

    @OneToMany
    public SkillEntity[] getSkills();
}

and

@Preload
@Table("SKILL")
public interface SkillEntity extends Entity {

   CategoryEntity getCategoryEntity();
   void setCategoryEntity(CategoryEntity category);

   int getSkillId();
   void setSkillId(int skillId);

   String getSkillTitle();
   void setSkillTitle(String skillTitle);

   String getSkillDescription();
   void setSkillDescription(String skillDescription);
}

and my query now:

@Override
    public List<SkillEntity> fetchSkillsByCategory(CategoryEntity category) {
        try {
            return Lists.newArrayList(ao.find(SkillEntity.class, Query.select().where("CATEGORY = ?", category)));
        } catch (Exception exception){
            return Lists.newArrayList();
        }
    }

but I still get one exception...


btw: Isn't category.getSkills() what you are trying to achieve? ;)

You should have a look at this sample code:

https://bitbucket.org/activeobjects/ao-dogfood-blog/src/42ae30d7c64e/src/main/java/net/java/ao/blog/service/AoBlogService.java?at=default

Oh, I just noticed, I got your question totally wrong. Of course CATEGORY can't be found because SKILL just has CATEGORY_ENTITY. But I'm not quite sure why it doesn't find this, too. How does your atlassian-plugin.xml look like?

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 Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

65 views 0 11
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