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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published yesterday in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

141 views 0 9
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