Git Product home page Git Product logo

Comments (2)

jcflack avatar jcflack commented on July 2, 2024

It's correct that there is no current support. What you would want to do would depend on exactly what your function wants to do with its JSONB arguments.

You might be stuck giving the arguments String type. That will require PostgreSQL to serialize the JSONB into JSON string form when calling the function, and then, adding insult to injury, if you wanted to act on the string as something structured, you would end up using one of the available Java JSON libraries to parse it again.

For XML, in contrast, an argument can be given the Java SQLXML type, which then allows structured manipulation with Java's (multiple!) batteries-included XML APIs.

Java has not adopted a batteries-included JSON API (though there are some quite widely used third-party libraries), so there is no equally obvious choice of a native Java type to which a JSON or JSONB argument should be mapped. Often, you would want to select your Java JSON library of choice, and then be able to supply an adapter mapping the PostgreSQL type onto that. That is getting into the territory of PR #399 and is not in any currently released PL/Java version.

PL/Java currently allows the pg_node_tree type to be received as a Java SQLXML argument, using a simple mapping of the node-tree syntax to XML, to which all the Java capabilities like XSLT, XPath, and so on can be applied. As far as a mapping for JSON that would not require external libraries, I am partial to implementing that same approach, using the standard XML representation of JSON defined by w3 XML Query. But that isn't implemented yet.

from pljava.

udesaiitrs avatar udesaiitrs commented on July 2, 2024

Okay understood, thanks for the detailed explanation @jcflack! We are constrained to JSON unfortunately for now. I will test the performance with what you suggested. Thanks again!

from pljava.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.