Good thoughts. I'd like to hear from others on this. I think iBatis should definitely try to help developers attack this problem (without trying to solve it directly -- a la Hibernate).
_________________ Patrick Lightbody Professional Services Jive Software [EMAIL PROTECTED] www.jivesoftware.com 317 SW Alder, Ste 500 Portland, OR 97204 ph (503) 295-6552 fx (503) 961-1047 -----Original Message----- From: Ron Grabowski [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 06, 2005 4:54 PM To: user-java@ibatis.apache.org Subject: Re: Vendor specific queries? You could create different property files per each vendor that contain database specific things (like the select key statement, GETDATE() , etc.) and use it this way: <selectKey keyProperty="ID" resultClass="long"> ${SELECT_KEY} </selectKey> Some people use this property syntax to group database specific sql maps: <sqlMap resource="/SqlMaps/${VENDOR}/Foo.xml"/> <sqlMap resource="/SqlMaps/${VENDOR}/Bar.xml"/> <sqlMap resource="/SqlMaps/${VENDOR}/Baz.xml"/> A colleague of mine suggested an alternative approach that hasn't been implemented yet. His idea is to add a namespace attribute to the statement node and allow that to override a particular statement node. For example if there are 30 statement nodes in Foo, Bar, and Baz and you need to override just one or two statement for Oracle you would be able to include the differing statements in their own small file: <update id="Update" namespace="Foo"> ... </update> <select id="GetMany" namespace="Bar"> ... </select> The resource nodes would look something like this: <sqlMap resource="/SqlMaps/Foo.xml"/> <sqlMap resource="/SqlMaps/Bar.xml"/> <sqlMap resource="/SqlMaps/Baz.xml"/> <sqlMap resource="/SqlMaps/${VENDOR}.xml"/> Yes, that would require you to always have a Oracle.xml, MSSQL.xml, etc. Maybe a "ignoreMissingSqlMapResource" setting is in order too ??? --- Patrick Lightbody <[EMAIL PROTECTED]> wrote: > Hey guys - great work on iBatis. I finally spent some time on it and > I > must say I prefer this method of storage much more than other options > out there. In fact, the next version of WebWork (which I am a > developer > for) will contain integration with iBatis. Now, on to my question: > > I've seen in the docs where vendor-specific features, especially > around > sequence handling, are done like so: > > <select name="insertFoo-ORACLE" .../> > <select name="insertFoo-MYSQL" .../> > > What I can't tell is if this is just some naming convention, or if > something trickier is going on here. Can iBatis run certain > "versions" > of a statement based on the database vendor it is currently connected > to? If not, maybe this would be a good feature to add? In fact, any > place a query could be written, if there could be an optional > "vendor" > attribute that could be used, that would be great. The end result > would > be: > > <select name="insertFoo" ...> > <selectKey keyProperty="ID" resultClass="long" > vendor="postgres"> > SELECT nextval('category_seq') as ID > </selectKey> > <selectKey keyProperty="ID" resultClass="long" > vendor="oracle"> > SELECT nextval('category_seq') FROM dual as ID > </selectKey> > INSERT ... > <selectKey keyProperty="ID" resultClass="long" > vendor="mssql"> > SELECT @@IDENTITY... > </selectKey> > </select> > > _________________ > Patrick Lightbody > Professional Services > Jive Software > [EMAIL PROTECTED] > www.jivesoftware.com > 317 SW Alder, Ste 500 > Portland, OR 97204 > ph (503) 295-6552 > fx (503) 961-1047