ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Ellis <ellis....@gmail.com>
Subject Re: How to programmatically add an xml mapping file to a Configuration?
Date Fri, 30 Apr 2010 09:21:32 GMT
On 30 April 2010 08:58, Joram Barrez <joram.barrez@gmail.com> wrote:
> However, I only have XML mapping files (so no mapper class). How can I
> add these to a Configuration? I can't seem to find the right method.

I've found this in my code, which seems a little complicated, but it
gets the job done.
It's code I wrote when I first started using iBATIS (early 3.0 betas),
so there might well be an easier way.

    private static void addSqlMappings(Configuration conf) {
        Map<String, XNode> xmlMap = new HashMap<String, XNode>();
        Reader map;
        try {
            map = Resources.getResourceAsReader("package/name/mapper.xml");
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
        XMLMapperBuilder xmlParser =
            new XMLMapperBuilder(map, conf, "mapper.xml", xmlMap,
ibatisNamespace);
        xmlParser.parse();
    }

Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message