path() and invoke() can take KProperty1 or KFuction1 as an argument. KFunction1 is useful when you use Java entity with private property and public getter.
If you want to use your own rule, implement JpqlPropertyIntrospector and provide it to RenderContext. See Custom DSL for more details. If you are using Spring, see Spring supports also.
classMyIntrospector : JpqlPropertyIntrospector() {overridefunintrospect(property: KCallable<*>): JpqlPropertyDescription? {if (property is KFunction1<*, *>) {val name =// resolve a name with your own rulereturnMyProperty(name) }returnnull }privatedataclassMyProperty(overrideval name: String, ) : JpqlPropertyDescription}val myModule =object : JpqlRenderModule {overridefunsetupModule(context: JpqlRenderModule.SetupContext) { context.prependIntrospector(MyIntrospector()) }}val myContext =JpqlRenderContext().registerModule(myModule)
// SELECT Book.isbn FROM Book AS Book WHERE Book.isbn.value = :param1jpql {select(path(Book::isbn), ).from(entity(Book::class), ).where(path(Book::isbn)(Ibsn::value).eq("01"), )}