Hi,
I am just getting into query dsl. I tested some simple queries that worked but got an “org.hibernate.hql.internal.ast.QuerySyntaxException” from the following query.
QTask task = QTask.task;
QAllocatable allocatable = QAllocatable.allocatable;
Session hibernateSession = (Session) entityManager.getDelegate();
JPQLQuery query = new HibernateQuery(hibernateSession).setReadOnly(true);
query.from(allocatable)
.innerJoin(allocatable.roster, roster)
.where(roster.id.eq(26192104));
query.list(allocatable);
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: from near line 2, column 1 [select
from de.ivu.mb.pdp.dispatch.local.allocatable.Allocatable allocatable
inner join allocatable.roster as roster
where roster.id = ?1]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54) [hibernate-core-4.2.17.S
I hope I am making just a simple mistake. Can you help?
My entities are annotated as follows:
@Entity
@Table(name = "Allocatable")
public class Allocatable
extends BaseEntityWithLongId
{
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "ROSTER_ID")
private Roster roster;
}
@MappedSuperclass
public abstract class BaseEntityWithLongId
@Entity
@Table(name = "Roster")
public class Roster
extends NamedEntity {
}
@MappedSuperclass
public abstract class NamedEntity
The following query worked:
query.from(allocatable)
.leftJoin(allocatable.roster, roster)
.where(allocatable.id.eq(new Long (121206561)));
List<Task> result = query.list(task);
Thanks,
Julian
--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
3.3.0