Active Objects SqlException by getting data

Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

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
Answer accepted
ConradR
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

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.

Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

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

Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

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...


ConradR
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

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

ConradR
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

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
TAGS
AUG Leaders

Atlassian Community Events