About SQL by Play

21 views
Skip to first unread message

KuoYing@Taiwan

unread,
Dec 17, 2010, 10:25:52 AM12/17/10
to play-framework
Hi all:
I'd like to query just like "select name from table" by SQL
How do I do by Play...
I try to coding........

List<ClickLog> name = ClickLog.find(?,?).fetch();

The Dave

unread,
Dec 17, 2010, 10:29:37 AM12/17/10
to play-framework
If ClickLog is a mapped entity object, you can do this:

List<String> names = JPA.em().createQuery("select name from
ClickLog").getResultList();

This will just return the list of names for the ClickLog table.

--Dave

KuoYing@Taiwan

unread,
Dec 17, 2010, 10:36:02 AM12/17/10
to play-framework
OK!! But if I want to do ClickLog.find(?,?)<-- don't the other way???
Message has been deleted

Julien Tournay

unread,
Dec 17, 2010, 10:39:41 AM12/17/10
to play-fr...@googlegroups.com
ClickLog.find("name = ?",name)

and btw:

jto.

On Fri, Dec 17, 2010 at 4:37 PM, KuoYing@Taiwan <stu93...@gmail.com> wrote:
OK!! But If I want to do ClickLog.find(?,?) <---don't the other ways??


On 12月17日, 下午11時29分, The Dave <the.dave.car...@gmail.com> wrote:
--
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.




--
Real Programmers don't need comments-- the code is obvious.

William Wong

unread,
Dec 17, 2010, 11:20:28 AM12/17/10
to play-fr...@googlegroups.com

This returns the list of field 'name' from the ClickLog entity:


List<String> names = JPA.em().createQuery("select name from
ClickLog where logtime > 123").getResultList();

This returns the list of ClickLog entities:

List<ClickLog> logs = ClickLog.find("name = ?",name);

They are for different purpose.


On Fri, Dec 17, 2010 at 7:37 AM, KuoYing@Taiwan <stu93...@gmail.com> wrote:
OK!! But If I want to do ClickLog.find(?,?) <---don't the other ways??

On 12月17日, 下午11時29分, The Dave <the.dave.car...@gmail.com> wrote:

Julien Tournay

unread,
Dec 17, 2010, 11:32:23 AM12/17/10
to play-fr...@googlegroups.com
Yep, sorry I read his message too fast ;)

jto.

KuoYing@Taiwan

unread,
Dec 17, 2010, 11:36:54 AM12/17/10
to play-framework
So.....how do I do^^? I didn't resolve it

On 12月18日, 上午12時32分, Julien Tournay <boudhe...@gmail.com> wrote:
> Yep, sorry I read his message too fast ;)
>
> jto.
>
>
>
>
>
>
>
>
>
> On Fri, Dec 17, 2010 at 5:20 PM, William Wong <williamw...@gmail.com> wrote:
>
> > This returns the list of field 'name' from the ClickLog entity:
>
> > List<String> names = JPA.em().createQuery("select name from
> >  ClickLog where logtime > 123").getResultList();
>
> > This returns the list of ClickLog entities:
>
> > List<ClickLog> logs = ClickLog.find("name = ?",name);
>
> > They are for different purpose.
>
> > On Fri, Dec 17, 2010 at 7:37 AM, KuoYing@Taiwan <stu93303...@gmail.com>wrote:
>
> >> OK!! But If I want to do ClickLog.find(?,?) <---don't the other ways??
>
> >> On 12月17日, 下午11時29分, The Dave <the.dave.car...@gmail.com> wrote:
> >> > If ClickLog is a mapped entity object, you can do this:
>
> >> > List<String> names = JPA.em().createQuery("select name from
> >> > ClickLog").getResultList();
>
> >> > This will just return the list of names for the ClickLog table.
>
> >> > --Dave
>
> >> > On Dec 17, 8:25 am, "KuoYing@Taiwan" <stu93303...@gmail.com> wrote:
>
> >> > > Hi all:
> >> > > I'd like to query just like "select name from table" by SQL
> >> > > How do I do by Play...
> >> > > I try to coding........
>
> >> > > List<ClickLog> name = ClickLog.find(?,?).fetch();
>
> >> --
> >> 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<play-framework%2Bunsubscribe@go oglegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/play-framework?hl=en.
>
> >  --
> > 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<play-framework%2Bunsubscribe@go oglegroups.com>
> > .

The Dave

unread,
Jan 25, 2011, 12:31:48 PM1/25/11
to play-framework
I'm confused, are you trying to:

1. Find a List<String>?

OR

2. Find a List<ClickLog>?

Are you trying to find a certain item in these lists?

--Dave

On Dec 17 2010, 9:36 am, "KuoYing@Taiwan" <stu93303...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages