I don't think so. The problem is that JPA and Scala can't work
together properly. There are many problems related to the way of Scala
annotations work, difference in the reflection API, no support for
Scala collection, requirement to use mutable state everything, etc...
> In some cases, I believe that JPA queries remain simpler than SQL (in yabe
> sample app, it's very clear).
Well, not sure. When I rewritten Yabe, I've changed a lot the way the
application access to the database to take part of the power of Anorm.
It can look more complicated but in fact it's just because it mostly
use only one request where hibernate was using several requests to
retrieve the same data set.
Anyway if you prefer something more ORM oriented than Anorm I suggest
you to look at pure Scala alternative like http://scalaquery.org/
instead of Hibernate. It just fits better with Scala.
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/ekUzNTl3blZWbXNK.
> 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.
>
--
Guillaume Bort, http://guillaume.bort.fr
This is a bit of a tangent, but I wonder if there is any interest in
decoupling Anorm from Play? It is a very useful and broadly applicable
bit of code. Allowing play-scala to be pulled in as an SBT project
dependency would achieve the same effect with much less work, I
imagine.
I had a stab at performing the decoupling but the validation
annotations require play.data.validation.
--
Brian L. Troutwine
I believe that's Sadek's intention. Actually if you look at Anorm's
code the only dependence on Play code is MayErr, which is a
self-contained 20 lines class.
> I had a stab at performing the decoupling but the validation
> annotations require play.data.validation.
I don't think validation is part of Anorm.
--
Erwan Loisant
on a related note:
- have you heard of ScalaJPA? I never used it myself, just bumped on
it while reading the scala-announcements list
(https://github.com/dchenbecker/scalajpa)
- what about java JPA Models and scala? (see
http://play.lighthouseapp.com/projects/74274-play-scala/tickets/17).
I'm pretty much interested in that one since I can patch every
upcoming play-scala version myself, but that does not feel very stable
on the long run.
> Well, not sure. When I rewritten Yabe, I've changed a lot the way the
> application access to the database to take part of the power of Anorm.
> It can look more complicated but in fact it's just because it mostly
> use only one request where hibernate was using several requests to
> retrieve the same data set.
I agree, Hibernate can lead to frighteningly bad performance by
churning out 4-5 queries where only one would be enough (and the
performance penalty for each additional query is big). But there are
ways to work around this, e.g. by writing the data fetching in one big
HQL query (instead of navigating the object model). And then the HQL
compiler can become pretty useful I would say.
Yabe is nice and all as a demo app, but for our application we're now
at 47 interconnected tables in the database (not our choice, the
domain model is big and getting bigger as we catch up with
functionality). And I for one do not want to write all the JOINs by
hand in SQL when a compiler can do that work for me.
One idea for the future: what about moving the JPA part of play-scala
into a separate module? That way:
- the interoperability with Java JPA models would be given again (as
long as not used together with the scala-jpa module)
- the interfaces for developing & maintaining another scala-jpa module
for folks that would like to use it anyway would exist.
Thanks,
Manuel
Yabe is nice and all as a demo app, but for our application we're now
at 47 interconnected tables in the database (not our choice, the
domain model is big and getting bigger as we catch up with
functionality). And I for one do not want to write all the JOINs by
hand in SQL when a compiler can do that work for me.
I agree, Hibernate can lead to frighteningly bad performance by
> Well, not sure. When I rewritten Yabe, I've changed a lot the way the
> application access to the database to take part of the power of Anorm.
> It can look more complicated but in fact it's just because it mostly
> use only one request where hibernate was using several requests to
> retrieve the same data set.
churning out 4-5 queries where only one would be enough (and the
performance penalty for each additional query is big). But there are
ways to work around this, e.g. by writing the data fetching in one big
HQL query (instead of navigating the object model). And then the HQL
compiler can become pretty useful I would say.
On Mon, Jun 6, 2011 at 7:40 PM, Sadek Drobi <sadek...@gmail.com> wrote:
>> Yabe is nice and all as a demo app, but for our application we're now
>>
>> at 47 interconnected tables in the database (not our choice, the
>> domain model is big and getting bigger as we catch up with
>> functionality). And I for one do not want to write all the JOINs by
>> hand in SQL when a compiler can do that work for me.
>
> The answer is: compiler can't. It is exactly in the context of complex model
> that frameworks like JPA fail and let you down. And you won't discover it
> until too late when you start having more than few users. That is our
> experience and that's the problem Anorm tries to target.
What I mean with "write JOINs by hand" is not to write the "on" part
or add a where constraint ("... and foo.barId = bar.id") where it is
clear from my relational model where I want to go. I don't expect
Hibernate to generate optimized queries, I just want to write
optimized queries myself in fewer words.
>>
>> > Well, not sure. When I rewritten Yabe, I've changed a lot the way the
>> > application access to the database to take part of the power of Anorm.
>> > It can look more complicated but in fact it's just because it mostly
>> > use only one request where hibernate was using several requests to
>> > retrieve the same data set.
>>
>> I agree, Hibernate can lead to frighteningly bad performance by
>> churning out 4-5 queries where only one would be enough (and the
>> performance penalty for each additional query is big). But there are
>> ways to work around this, e.g. by writing the data fetching in one big
>> HQL query (instead of navigating the object model). And then the HQL
>> compiler can become pretty useful I would say.
>
> So this is contradictory. Hibernate will save you writing joins and you'd
> replace them with HQL fetches? That clearly shows that the model
> is unintentionally leaky. You define your model upfront not to write queries
> and then you revert to queries because the model doesn't work!
I personally didn't revert to queries, I started writing queries right
from the beginning whenever possible because I know too well that
Hibernate won't make nice ones itself. So as said, I don't have many
expectations from HQL - I just expect to write less verbose queries,
that's it.
Just to be clear - I agree with the problem you're trying to solve,
where Hibernate starts working against you instead of for you. All I'm
asking for is to know if there's going to be a place in the future of
play-scala for folks like me who are happy with writing queries by
hand in HQL and/or have an existing Play application written in
play-java and would like to slowly migrate to play-scala.
Manuel
>
> Sadek
> --
> www.sadekdrobi.com
> ʎdoɹʇuǝ
With this kind of reasoning we'll be all using cobol today.
> The existing JPA play infrastructure also allows the use of multiple
> different database backends, and can even be adapted to other stores,
> as is seen with the Morphia plugin.
>
> Anorm forces you to use a RDBMS currently.
Obviously, if you don't want to use a relational database you don't
want to use Anorm. This is actually not going to change: Anorm will
never get a MongoDB backend. This doesn't mean you must use Anorm in
your play scala projects.
I don't think having a common abstraction layer on the top of
relational databases and json databases like MongoDB. They have a very
different approach, so the you should think carefully when you decide
which one you use at the beginning of your project. It doesn't make
much sense to switch from one to the other without a major rewrite of
your models.
> Anorm is immature and too feature incomplete currently to even hope to
> displace the JPA support in Play-Scala.
No matter how you like JPA, it doesn't work correctly with Scala. Even
if you don't like Anorm you should still use a non-JPA Scala ORM, like
Circumflex ORM for example.
--
Erwan Loisant
ScalaQuery and Anorm could work together, Is there any example?
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/Lw5YOPooH88J.