QuerySyntaxException in simple join query

586 views
Skip to first unread message

Julian

unread,
Mar 8, 2015, 2:02:53 PM3/8/15
to quer...@googlegroups.com

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

Timo Westkämper

unread,
Mar 8, 2015, 2:04:20 PM3/8/15
to Querydsl on behalf of Julian
Hi.

Which Querydsl version do you use?

Br,
Timo

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

Julian

unread,
Mar 8, 2015, 3:53:23 PM3/8/15
to quer...@googlegroups.com
3.3.0

timowest

unread,
Mar 9, 2015, 4:39:30 PM3/9/15
to quer...@googlegroups.com
Could you try 3.6.2?

On Sunday, March 8, 2015 at 9:53:23 PM UTC+2, Julian wrote:
3.3.0

Julian

unread,
Mar 10, 2015, 4:54:41 PM3/10/15
to quer...@googlegroups.com
I will be back in office next week. I will try and tell you if it worked.
Reply all
Reply to author
Forward
0 new messages