Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any chance of integrating QueryBeans support? #2

Open
corrspt opened this issue Apr 4, 2017 · 10 comments
Open

Any chance of integrating QueryBeans support? #2

corrspt opened this issue Apr 4, 2017 · 10 comments

Comments

@corrspt
Copy link

corrspt commented Apr 4, 2017

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)

@thibaultmeyer
Copy link

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.

@corrspt
Copy link
Author

corrspt commented Apr 5, 2017

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?

@corrspt corrspt changed the title Any change of integrating QueryBeans support? Any chance of integrating QueryBeans support? Apr 5, 2017
@rbygrave
Copy link

rbygrave commented Apr 5, 2017 via email

@thibaultmeyer
Copy link

thibaultmeyer commented Apr 5, 2017

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.

@corrspt
Copy link
Author

corrspt commented Apr 18, 2017

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.

@rbygrave
Copy link

rbygrave commented Apr 18, 2017 via email

@thibaultmeyer
Copy link

Hi Rob,

Thank for your time. I will take a look at these two generators.

@thibaultmeyer
Copy link

@rbygrave , it seems that import Generator and GeneratorConfig are no longer provided by querybean-generator ("io.ebean" % "querybean-generator" % "10.1.3")

image

image

@corrspt
Copy link
Author

corrspt commented Nov 5, 2017

Pinging @rbygrave in hopes you by any chance have the free time to contribute again :)

@coreycaplan3
Copy link

coreycaplan3 commented Nov 9, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants