1

From what I read from the docs it looks like MyBatis doesn't support type handling for Postgres Network Address types. It would have been nice if it were a first class JDBC type.

Has anyone tried/written a custom type handler to deal with this? Any suggestions?

Thanks

7
  • 1
    We may need more info to answer. You should show what you tried (table, class, mapper, type handler, etc.) and how it failed. Commented May 20, 2023 at 8:06
  • 1
    I tested String vs. MACADDR mapping. Retrieval seems to work out-of-the-box. Setting parameter may require a custom type handler. See the demo. If you need further help, please update the question to be more specific. Commented May 21, 2023 at 14:50
  • @ave Thank you for your time & help! I am sorry I didn't add more info specially w.r.t to my knowing that I can definitely use PGObject & write a custom type handler. I was more interested in knowing/hearing from MyBatis community folks on whether they have any plans to support this natively & from other users on whether they had any problems with using PGObject. Commented May 22, 2023 at 20:49
  • I will add an example of the above & try it out & share here shortly. But please feel free to add your above comment as answer & I will accept it. Commented May 22, 2023 at 20:53
  • 1
    Assuming String is used to store these values in your code, I don't see the point in involving PGObject in a type handler, but in any case, there won't be 'native support' from MyBatis unless these network types are added to the JDBC API. In MyBatis users' questions, I rarely see these network address types being used. My guess is that people prefer casting them in SQL rather than writing custom type handler because it's simpler. Commented May 23, 2023 at 16:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.