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!!!
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
btw: Isn't category.getSkills() what you are trying to achieve? ;)
You should have a look at this sample code:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.