error using @SqlSelect

25 views
Skip to first unread message

opoppon

unread,
Jul 2, 2009, 3:29:36 AM7/2/09
to Ebean ORM
Hello
I have declared a sql query in an entity (Candidate):

@Sql(select= {
@SqlSelect(name="Candidate.FindAllCandidateWithRegistration",
query="SELECT c.id, c.firstname, c.lastname, c.company, c.phone,
c.email from candidates c, registrations r WHERE r.candidate_id =
c.id",
debug=true
)
}
)

I call it like this:
List<Candidate> list = Ebean.createQuery(Candidate.class,
Candidate.FindAllCandidateWithRegistration").findList();

In the console, Ebean parses the query correctly, but findList()
fails, complaining that it is called on a null object.
So it looks like the Query object could not be created after all.
I have based my code on the PDF document (ebean doc v 1.1) chapter
3.1.2, though I am using ebean 1.2.

Do you spot any mistake in the way I have coded this?

THanks
Olivier

Rob Bygrave

unread,
Jul 2, 2009, 3:59:12 AM7/2/09
to eb...@googlegroups.com

No, it looks ok.

Does this mean Ebean.createQuery(Candidate.class,"Candidate.FindAllCandidateWithRegistration") returns null?

Can you include the stack trace?

Liu Nathan

unread,
Jul 2, 2009, 4:02:14 AM7/2/09
to eb...@googlegroups.com
here is it.
--
Best whishes to you!
Thanks for your consideration!
NathanLiu

Liu Nathan

unread,
Jul 2, 2009, 4:04:43 AM7/2/09
to eb...@googlegroups.com
it is a bug. Every entity needs a @Id, or

Rob Bygrave

unread,
Jul 2, 2009, 5:09:05 AM7/2/09
to eb...@googlegroups.com
Yes, its an existing bug.  Actually Bug 120... not Bug 121.  Fixed in HEAD so will be in the next release.

http://www.avaje.org/bugdetail-120.html

If you enter an where clause ... like "1=1" ..should get around the issue until the next release.


Cheers, Rob.
Reply all
Reply to author
Forward
0 new messages