Mybatis and YAML

54 views
Skip to first unread message

Ben Pracht

unread,
Sep 22, 2026, 3:21:07 AMSep 22
to mybatis-user
I've been on projects wherein Mybatis would've been a more optimal fit, but the use of XML is a strong deterrent. I have a fork of this that allows the overwhelming bulk of a MyBatis project to use zero XML and all YAML. The 

Advantages of this are:
* No escaping of SQL when special characters are involved. For example, SELECT * from Account where balance > 50 rather than SELECT * from Account where balance > 50;
* Easier to fit on one line or copy/paste from a SQL engine
* Adaptable to SpringBoot application.properties format.
* Indention can be more natural rather than indenting around XML elements, or keeping an ugly XML formatting just so the SQL can be better formatted.

I doubt I'm the first to think of this, but in case I am, attaching is a fork of the repo as a starting attempt. Please let me know what you think.

https://github.com/bpracht/mybatis-3

Regards

aa

unread,
Sep 22, 2026, 5:18:13 AMSep 22
to mybati...@googlegroups.com
YAML sucks. I much prefer writing x10 the amount of code than having to deal with YAML indentation crap. 

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mybatis-user/49c007be-1308-4f5b-a6ae-36b646018e4fn%40googlegroups.com.

Mark Nolan

unread,
Sep 22, 2026, 5:33:13 AMSep 22
to mybati...@googlegroups.com
The whole Python universe just poked its head up to hear what you had to say about indentation! So, YAML sucks for you, but lots of people love it: why wouldn't you support it if you can? 

Ben Pracht

unread,
Sep 22, 2026, 11:04:36 AMSep 22
to mybati...@googlegroups.com
I appreciate even the negative thoughts :)

Having said that, I like MyBatis as part of a Java tech stack and lament the use of Hibernate and descendent tech. I believe in knowing the SQL your code uses and not letting a stack invent some slow implementation. This MB deserves much more mind share.

Having said that, this YAML support is intended to exist on a 1:1 basis with XML.

Best Regards,
Ben Pracht
919.809.2439
ben.p...@gmail.com

You received this message because you are subscribed to a topic in the Google Groups "mybatis-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mybatis-user/4C8HY6rIFQg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mybatis-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mybatis-user/CAENMeXmo25w7jqcHKChm9-KX2gKJzKaJZRj2JYQP5CwxsK6giw%40mail.gmail.com.

Clinton Begin

unread,
Sep 22, 2026, 2:01:24 PMSep 22
to mybati...@googlegroups.com
This was a very early consideration. At the time XML was chosen partly because the industry had adopted it. Over time YAML and JSON have definitely replaced most XML in the mainstream. That said, JSON is entirely inappropriate due to significant limitations regarding metadata, strings, and structure (or you know... comments). YAML, on the other hand, could do the job, but is more prone to whitespace and scaling issues as files get large. Interestingly, these days it should matter less that it's XML, since your AI tooling should write a good amount of it for you (at the very least as an augment to hand typing). The same could be said of YAML, though. I think YAML is somewhat more efficient for AI models to process (if it's kept simple -- YAML is actually an incredibly huge specification that includes the entirety of JSON as well; yes, JSON is valid YAML). Therefore, we could consider alternative formats. These days, porting existing XML files and / or porting the MyBatis parsers to support other formats is quick work for an AI model. In short, the format that envelops the MyBatis data structure and your SQL should matter very little. I think one early goal we had years ago was to integrate it into the Java language in a way that didn't entirely suck. But Java at the time also lacked decent abstractions for supporting such a thing (C# as an example had much better capabilities here). Also on the list of considerations was a completely custom format or DSL. I think there were some early third-party attempts at this. Nice trip down memory lane, and nice to see XML still hanging on 25 years later. :-) 

Clinton

Ben Pracht

unread,
Sep 22, 2026, 7:57:34 PMSep 22
to mybati...@googlegroups.com
I figure this update gives people options they wouldn't otherwise have. If you have a chance, please check our the PR. Not sure how contributions work on this project but  I'd love to get a change like this into MyBatis.
Reply all
Reply to author
Forward
0 new messages