Community
Participate
Working Groups
I'm trying to follow Play! framework's tutorial but in xtend: http://www.playframework.org/documentation/1.2.4/guide2 I have this line in a text class in xtend: val User bob = User::find("byEmail", "bob@gmail.com").first(); And I expect it to be compiled to this Java code, or something similar: User bob = User.find("byEmail", "bob@gmail.com").first(); In reality, I get this generated Java code: JPAQuery _find = GenericModel.find("byEmail", "bob@gmail.com"); User _first = _find.<User>first(); final User bob = _first; Note that it's using GenericModel, which is the parent of the parent class of User, and not the User class itself. When running the test class, I get this error: A java.lang.UnsupportedOperationException has been caught, Please annotate your JPA model with @javax.persistence.Entity annotation. In /test/BasicTest.java, line 18 : JPAQuery _find = GenericModel.find("byEmail", "bob@gmail.com"); The detailed traceback is posted at the end of the email. My guess is that although my model class User extends Model class which extends GenericModel, when xtend compiler decide to use GenericModel (why?) instead of User, it loses the annotation @javax.persistence.Entity that the User class has. Is this a compiler error? Is there any reason to not use the class in the xtend code and use its parent's parent instead? ----------------------------- The original tutorial is in Java, and the Java version works fine. The difference is that it uses the find() method on the User object, which has @Entity annotation. User bob = User.find("byEmail", "bob@gmail.com").first(); The generated Java file uses GenericModel instead, although in xtend source, I have User::find(). GenericModel doesn't have @Entity annotation although I'm not sure if it's the problem. It's the difference, though. GenericModel.find("byEmail", "bob@gmail.com"); I think find() is added by JPA @Entity. GenericModel has a find() method defined to catch the error in case the model class, in this case the User class, does not have @Entity annotation: public static JPAQuery find(String query, Object... params) { throw new UnsupportedOperationException("Please annotate your JPA model with @javax.persistence.Entity annotation."); } Comment from Sven: at compile time there is no static method 'find' in your domain model class. I assume that play! does some magic during class loading and adds the 'find' method to your class. Generally what Xtend does is ok and valid, but it doesn't 'play' nicely with such magic. Please file a bugzilla, so we can discuss the issue there and maybe fix it if it doesn't break anything else.
pushed to master
Closing all bugs that were set to RESOLVED before Neon.0