Pregunta

I need to select all articles who do have work flow tasks associated with them. I tried to use the following JPA query (icm with the Play! Framework, JPA, Hibernate):

 List<Article> list = find("site.app=? AND workflowSteps IS NOT EMPTY ORDER BY pubDate DESC", app).fetch();

But this gives the fool wing error:

IllegalArgumentException occured : org.hibernate.hql.ast.QuerySyntaxException: workflowStep is not mapped [from models.Article where site.app=? AND workflowSteps IS NOT EMPTY ORDER BY pubDate DESC]

The relevant code for the entities are:

@Entity
public class Article extends TemporalModel {

    @OneToMany(mappedBy = "article", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
    public List<WorkflowStep> workflowSteps;
}

@Entity
public class WorkflowStep extends TemporalModel {

    public WorkflowStepType type;

    @Required
    @ManyToOne
    @JoinColumn(name="article")
    public Article article;
}

Is this possible this way, and if so, what am I doing wrong?

No hay solución correcta

Otros consejos

You must map your entities to their respective tables and add @Table annotations:

@Entity
@Table(name="ARTICLE")
public class Article extends ....

.....

@Entity
@Table(name="WORKFLOW_STEP")
public class WorkflowStep extends ....

QuerySyntaxException:It seems your query class name is not correct. In the HQL , you should use the java class name and property name of the mapped @Entity instead of the actual table name.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top