We use Play at work. It's the only reason I use an Algol dialect after 10 years of writing Lisps. It and Android, to be frank.
I believe we have one of the largest Play code bases. And I still enjoy it.
I picked it out of a line up, I tested Django, Rails, Cake, Java EE and buncha other stuff. I had just a month to pick a platform and budget limits for 4 staff and 2 years. So far I only needed just a gfx designer and I still do all coding myself.
I'm one of those programmers that can't ignore the implementation language. I don't do 2nd-class languages without understanding their host environment fully.
Thanks for the offer. I've also just started using Play at work and one question has been driving me nuts: I'm trying to form a many-to-many relationship with JPA.
I have two models, with a third model to represent the relationship (can't just use @ManyToMany as the relationship has attributes).
The primary key on the relationship model is a composite primary key of two other models.
When I add a new relationship model to the @OneToMany set on one of the first models, can I get the relationship model's key to change automatically, or do I have to do it manually?
e.g. with three models like (psuedo-Java-Scala coming up)
class Order(val customerName)
@OneToMany
Set<OrderItem> items;
class Item(itemDescription)
@OneToMany
Set<OrderItem> orders;
class OrderItem(val quantity)
@Id
@PrimaryJoinColumn
@ManyToOne
Order order;
@Id
@PrimaryJoinColumn
@ManyToOne
Item item;
OrderItem oi;
oi.item = bananas;
order.items.add(oi);
order.save(); // This saves oi, but with a null value for order_id
oi.order = order; //This seems redundant, but the save is wrong without it.
It seems like I have to do it manually, but to my mind adding it to the Set should be enough information to change the keys. Is my thinking wrong or am I using JPA wrong?
Yep, you figured it out. JPA requires you to set it on both sides. (Well, really you only HAVE to set it on the owning side of the association, which is what Hibernate monitors, but you should do both. Otherwise, a future programmer may be surprised that the objects don't have a consistent view of the association later on.
Yeah, I can't believe JPA/most ORMs don't maintain both sides of a relationship. That sort of stuff should just work.
I implemented my own ORM (http://joist.ws) a few years ago to solve this and my other JPA/Hibernate annoyances. It works really well, modulo the fact that I suck at docs/promotion/etc. so it doesn't have many users (working on that).
Also note that, specific for the playframework, someone seems to have implemented the necessary magic in a plugin:
Which is nifty, other than I'm slightly wary of the "magic that happens via runtime class rewriting" that seems to be Play's standard way of doing things. The results are admittedly impressive, but it seems like you're coupling yourself to yet-another-runtime-environment/container for things to work right.
I had a similar problem to this, it pissed me off the ages although I did spend allot of time trying to do it with @ManyToMany as having a separate Entity just for the relationship seemed like bloat to me.
As I recommended before, read the book "Java Persistence with Hibernate" and things will start to make more sense.
Hibernate is generally far more concerned with being flexible and robust than it is with being DRY or providing a perfect database abstraction. You really do still have to think about your data from the point of view of the DBMS regards 'Owning' Associations etc.
One thing with Play! is that it does try to over abstract hibernate a little bit and turn it into ActiveRecord which is fine for simple things but hibernate is not like ActiveRecord!
B-b-b-but DRY. Okay, thanks for reassuring me I'm not doing it wrong and there's not a @UpdateAutomaticallyLikeActiveRecord annotation I'm missing or something :)
Have you written any 'rich' clients with it? If so have you used GWT with it what was that like? If you didn't use GWT what was it like to use javascript with it and what libs did you use?
I heavily use its Jobs to keep ajax responsive. I do full-text autocompletion off of Postgres' native seaorch against 65k products. Works great. Its a great piece of software, see chat demo for Comet example.
I've used Play! for work and personal projects, and I've never had to deal with XML. Play uses .properties files for simple things (actually, there's just one main .properties file), YML for more complex data (like a list of fixtures to load for unit testing), and "convention" for pretty much everything else (that is, you don't have to write any configuration if you put things in the places where Play expects them)
Play's simplicity and its favouring of 'getting-shit-done'-attitude over the 'layering-and-overarchitecting'-attitude in the Java community has greatly benefited its rise. I really hope this type-safe Scala reimplementation of the framework pays off and is not a step backwards.
We're still in line with our "no useless boilerplate" approach in Play 2.0. You can look at the samples and make up your own mind about whether we've been successful or not:
Agreed, I'm not going to say Java syntax is awesome (it's not), but I think the "over-architecting" attitude you mention has done far more to drive people away from Java (e.g. the great Ruby exodus) than the syntax itself.
We use Play heavily at work (eg. 50k SLOC). I love it.
However, I'm pretty nervous about 2.0, due to the tight coupling with Scala. I still have a bad taste in my mouth from trying to use Lift, and I did not care for sbt at all.
While typesafe templates seem like a good thing, I can't recall ever having bugs that would have been caught by them, and it looks like it will eliminate the magical boilerplate-free parameter passing from the current version of Play.
In two full days of effort, I couldn't get a simple set of pages done. I found Play! right after that, and finished the pages completely painlessly in roughly no time.
I would chalk it up to terrible terrible documentation, and being unable to read the example code that I did find due to the Scala practice of using random characters as method names. e.g. something = x % y %% z ||| a
The documentation was really the worst, though. Maybe it's improved in the last year.
Wow these are really great news. Already used Play 1.2.3 and this was already amazing easy to work with.
Working now with grails 1.3.7 and I definitely will change to Play after finishing my current project.
Grails is a pain and it doesnt feel very light as its built uppon the spring stack which is huge. Using plugins is sometimes risky as they are outdated and you dont really understand what they are doing in the background.
I also like the type safe approach of Scala/Java which you dont have in grails(groovy/java). This is also very useful for code completion in IDEs
Play framework is a breath of fresh air compared to other Java frameworks. The only disadvantage I can see is that allot of the features to make things simpler do seem to more tightly couple you to it.
I think the overarching fear of tight coupling is what drove enterprise Java to the brink of madness. I blame people who got screwed by frameworks like EJB (pre-3) and Struts (pre-2.0). After the frustration of being "stuck" with these architectural decisions, the community did a 180 and went to excessively loose coupling and fear of inheritance.
Now the complexity of frameworks like Spring and Hibernate drive people away from Java because setting up a simple website is such a chore. It seems like libraries like Play and Stripes aim for the middle ground that makes web platforms like Rails and Django so popular.
Admittedly, they serve different audiences. It seems like frameworks like Play are better aimed at simple public websites and not "enterprise web services" or whatnot. And that's fine.
Play framework uses hibernate + JPA under the hood (although you may be able to switch it for something else) but provides so much candy around it that it feels like using Doctrine or something.
This isn't a bad thing as hibernate is an extremely powerful and complete ORM which I trust allot more than any of the half baked ones.
If you want to use hibernate properly I recommend reading "Java Persistence with Hibernate" It explains the framework very well including the logic behind allot of the things that feel strange or over engineered with it.
I just spent 20 minutes reading through the documentation and the changes look very good! I sometimes use Play for my own projects and I was very disappointed to not have been able to talk my largest customer into using Play when we kicked off two new projects 5 months ago. Oh well.
Play makes Java (or Scala) web development a light and fun experience.
I dinked around with Play a while ago and was impressed all around. However, am I the only one who thinks it would benefit immensely from a better name?
"Play" just makes it sound so... unrobust. It needs a name that conveys that it's industrial-strength. How about Chupacabra or Lugwrench or Nailgun or ...
I believe we have one of the largest Play code bases. And I still enjoy it.
I picked it out of a line up, I tested Django, Rails, Cake, Java EE and buncha other stuff. I had just a month to pick a platform and budget limits for 4 staff and 2 years. So far I only needed just a gfx designer and I still do all coding myself.
Ask me anything about Play.