Open corrspt opened 7 years ago
Hi,
QueryBeans is a really nice evolution but to be honest we have try (many times) to test QueryBeans in a simple Maven project... we only get NullPointerException :-(
Since, @rbygrave have done a lot of modifications like merging Ebean Agent and Ebean QueryBeans Agent into a single agent, maybe, in a near futur, he will achieve modifications to get QueryBeans as simple as "standard" query system.
Of course, you are welcome to propose a pull request if you succeed to implement QueryBeans.
Sincerely.
I would absolutely propose a PR if I had been able to do it, but I haven't been able as well. 👎 Thanks for the reply, should I close the issue?
> test QueryBeans in a simple Maven project... we only get NullPointerException :-(
Are you are unable to git pull and run the example application? ... https://github.com/ebean-orm-examples/example-java8
On 5 April 2017 at 21:52, Pedro Rio notifications@github.com wrote:
I would absolutely propose a PR if I had been able to do it, but I haven't been able as well. 👎 Thanks for the reply, should I close the issue?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/payintech/play-ebean/issues/2#issuecomment-291812209, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMwTTaLzFoJ98fOh2XYVTJuf_GPq-Neks5rs2R2gaJpZM4MzJXg .
Hi @rbygrave,
the Java 8 example run very well (mvn test). But I dont find the ebean-agent ? All the "magic" seems done by a Maven plugin.
Currently, this project (play-ebean) is using ebean 10.2.1 and ebean-agent 10.1.7. The enhancement is performed with the class "OfflineFileTransform" provided by Ebean. Here the Scala code:
// Ebean enhancement
def enhanceEbeanClasses(classpath: Classpath, analysis: Analysis, classDirectory: File, pkg: String): Analysis = {
// Ebean (really hacky sorry)
val cp = classpath.map(_.data.toURI.toURL).toArray :+ classDirectory.toURI.toURL
val cl = new java.net.URLClassLoader(cp)
val t = cl.loadClass("io.ebean.enhance.Transformer").getConstructor(classOf[ClassLoader], classOf[String]).newInstance(cl, "debug=0").asInstanceOf[AnyRef]
val ft = cl.loadClass("io.ebean.enhance.ant.OfflineFileTransform").getConstructor(
t.getClass, classOf[ClassLoader], classOf[String]
).newInstance(t, ClassLoader.getSystemClassLoader, classDirectory.getAbsolutePath).asInstanceOf[AnyRef]
ft.getClass.getDeclaredMethod("process", classOf[String]).invoke(ft, pkg)
analysis
}
Do you have any advice how to enhance this project to get working with QueryBeans ?
I suspect it only missing the Qxxxxxx (eg: QAccount) class generation...
Sincerely.
Sorry for pinging you @rbygrave , you probably haven't responded because you're busy, but if by chance you missed @0xbaadf00d reply, it's just to bring it to your attention again as It would make us Play Framework users very happy to have query beans working.
Thanks for the support and great work on Ebean.
No problem. Yes I did see it, yes I'm really busy at the moment.
There are 2 query bean generators
the Java processing one https://github.com/ebean-orm/querybean-generator
the ASM bytecode one .. https://github.com/ebean-orm-tools/finder-generator (generates Kotlin or Java query beans based on reading the meta data from .class files via ASM)
The ASM based one can be used via maven plugin https://github.com/ebean-orm-tools/codegen-maven-plugin ... with some interesting code in: https://github.com/ebean-orm-tools/codegen-maven-plugin/blob/master/src/main/java/io/ebean/codegen/Generate.java
On 18 April 2017 at 22:34, Pedro Rio notifications@github.com wrote:
Sorry for pinging you @rbygrave https://github.com/rbygrave , you probably haven't responded because you're busy, but if by chance you missed @0xbaadf00d https://github.com/0xbaadf00d reply, it's just to bring it to your attention again as It would make us Play Framework users very happy to have query beans working.
Thanks for the support and great work on Ebean.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/payintech/play-ebean/issues/2#issuecomment-294772919, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMwTfND--1ngM2yiuONmXsQgDiu3aITks5rxJHAgaJpZM4MzJXg .
Hi Rob,
Thank for your time. I will take a look at these two generators.
@rbygrave , it seems that import Generator
and GeneratorConfig
are no longer provided by querybean-generator ("io.ebean" % "querybean-generator" % "10.1.3")
Pinging @rbygrave in hopes you by any chance have the free time to contribute again :)
What is the state of this PR as of now? I've been running a "modified approach" of using the static alias instance of the Query-Bean class and calling toString on the properties to still get some type safety. I would love to migrate this:
Ebean.createQuery(InvitedUser.class).where().eq(QInvitedUser.alias().email.toString(), email).findOne()
To some real type safety goodness, and still be able to use Play!
The only reason why this works, is because enhancement initializes the fields in the alias static instance but not any of the other (non-private) constructors. Interesting dilemma. I would like to fix it myself if time permitted.
Note: without this workaround, I get NullPointerExceptions, like everyone else. This also does not support nesting unfortunately, since I can't call "toString" to get the name of the property in the owning model.
This was never integrated in play-ebean as such I don't think there's currently a way to use QueryBeans in a Play Framework project? Would be really nice to be able to use them.
Thanks for the project in any case, really helpful to keep with the latest Ebean versions (started using this week)