[Lift] Re: scalar queries in Lift/JPA

2009-04-25 Thread Oliver Lambert
Sorry, I didn't get back sooner - too much work! No one told me I couldn't do this so I just did it. Create a dummy entity to a table/view that doesn't exist - then write a query that uses column aliases and any arbitrary sql to populate that entity. I guess JPA/Hibernate is just creating an

[Lift] Re: scalar queries in Lift/JPA

2009-04-25 Thread Derek Chen-Becker
Nice. I'm a fan of when in doubt, do it anyway :) On Sat, Apr 25, 2009 at 6:34 AM, Oliver Lambert olambo...@gmail.com wrote: Sorry, I didn't get back sooner - too much work! No one told me I couldn't do this so I just did it. Create a dummy entity to a table/view that doesn't exist - then

[Lift] Re: scalar queries in Lift/JPA

2009-04-24 Thread Bryan.
I've never tried this on a scalar query, but a constructor expression example should be something like this: select new com.chas.values.AnswerCount(t.answer, count(distinct answer)) from ... class AnswerCount(answer: String, count: Long) { private def nullToOption[T](v: T) = v match { case

[Lift] Re: scalar queries in Lift/JPA

2009-04-23 Thread Oliver Lambert
Is there anything to stop you defining an class/entity {answer: String, countAnswer: Int} and to directly create it from JPA (of course, it's read only). On Wed, Apr 22, 2009 at 9:36 AM, Charles F. Munat c...@munat.com wrote: I was thinking tuples, but that didn't work. I'll try your

[Lift] Re: scalar queries in Lift/JPA

2009-04-23 Thread bradford
Are you referring to Constructor Expressions? On Apr 23, 9:23 am, Oliver Lambert olambo...@gmail.com wrote: Is there anything to stop you defining an class/entity {answer: String, countAnswer: Int} and to directly create it from JPA (of course, it's read only). On Wed, Apr 22, 2009 at 9:36

[Lift] Re: scalar queries in Lift/JPA

2009-04-23 Thread Charles F. Munat
I'm not really sure how I would go about this, but I'll think about it when I have time to get back to that code. Thanks, Oliver. Chas. Oliver Lambert wrote: Is there anything to stop you defining an class/entity {answer: String, countAnswer: Int} and to directly create it from JPA (of

[Lift] Re: scalar queries in Lift/JPA

2009-04-23 Thread Derek Chen-Becker
Oliver, I've never done anything like that in JPA or Hibernate. Is that actually possible? Can you create a class instance within a query? Derek On Thu, Apr 23, 2009 at 2:47 PM, Charles F. Munat c...@munat.com wrote: I'm not really sure how I would go about this, but I'll think about it when

[Lift] Re: scalar queries in Lift/JPA

2009-04-21 Thread Derek Chen-Becker
I think that the type would be Array[Any] and you'll get one String and Int for each row. Derek On Tue, Apr 21, 2009 at 3:37 PM, Charles F. Munat c...@munat.com wrote: Anyone have a quick example of how to run a scalar query in JPA? I can't find anything in the JPA demo. I have this query:

[Lift] Re: scalar queries in Lift/JPA

2009-04-21 Thread Charles F. Munat
I was thinking tuples, but that didn't work. I'll try your suggestion. BTW, for anyone reading along, I forgot the group by clause in the query below. Chas. Derek Chen-Becker wrote: I think that the type would be Array[Any] and you'll get one String and Int for each row. Derek On