QuerySyntaxException on outer join

173 views
Skip to first unread message

Carlos Ferreyra

unread,
Jan 18, 2010, 4:05:39 PM1/18/10
to play-framework
Hi everyone,

I'm building a simple webapp to learn play! and has been great so far
(really great), except for this hibernate exception I can't seem to
workaround.

I have a Language class:

@Entity
public class Language extends Model {

@Required
@MaxSize(2)
@Column(unique=true)
public String code;

@Required
public String name;

@OneToMany(mappedBy = "language", cascade = CascadeType.ALL)
public List<Text> texts = new ArrayList<Text>();
}

... and a Text class:

@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames =
{"language_id", "code"}))
public class Text extends Model {

@Required
public String code;

@ManyToOne
public Language language;

@Lob
@Required
public String text;
}

I'm trying to obtain a count using this sentence:
Text.count("from Text t left join Language l");

----------SKIP----------
Useless rationale: This is a sample translations application, I have
languages and text for each language, each text has a code. This query
comes from the idea of searching by language and code so you can fetch
a code and enter the text for each language.
----------SKIP----------

... and I'm getting this error:

IllegalArgumentException occured :
org.hibernate.hql.ast.QuerySyntaxException: Path expected for join!
[select count(*) from models.Text t left join Language l]

It complains about not knowing how to connect the two entities even
though I annotated the properties in each class. This seems to be
proved by the fact that in the error message the Language class has
not been converted to "models.Language" like Text.

Converting the query to explicit join (like "from Text t, Language l
where t.language = l") strangely works, but that's an inner join,
which is not what I want.

Thanks in advance for any help with this issue,
Carlos.

Guillaume Bort

unread,
Jan 18, 2010, 4:17:10 PM1/18/10
to play-fr...@googlegroups.com
I think that the correct query is: Text.count("from Text t left join
t.language");

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>
>
>

Carlos Ferreyra

unread,
Jan 18, 2010, 4:26:06 PM1/18/10
to play-fr...@googlegroups.com
Indeed, and now I feel like a real n00b!

Thanks for your help Guillaume!

2010/1/18 Guillaume Bort <guillau...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages