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

0 votes
Accepted answer

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
Community showcase
Posted yesterday in Canada

Happy New Year - First AUG of the year - great success

Hi Everyone, Hope everyone had a great holiday season and is ready for an exciting 2019.  We had our first AUG last night featuring Tempo Timesheets.  A great presentation and lots of int...

15 views 0 1
View post

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