ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: SQL fragment does not respect namespaces in 2.2.0 beta
Date Mon, 28 Aug 2006 15:58:42 GMT
I am wondering if the client should throw an exception if the id of an
element contains a dot - since it causes what I would consider
unexpected behavior, I think it should.

Essentially, what this is doing is letting you silently create (or
replace) an element in another namespace.

Larry


On 8/28/06, Scott Warner <swarner@adcc.com> wrote:
> Thanks, I wouldn't have thought of that because it has been working just
> fine until this release.
> I will change my ids and namespaces (I use periods there too).
>
> Scott Warner
>
> Larry Meadors wrote:
> > OOOOhhhhhh...OK.
> >
> > Using a "." in an id confounds the namespace stuff..I am really
> > suprised that it works in 2.1.7 - it shouldn't.
> >
> > I'd suggest changing the id from "Results.Fields" to "ResultsFields"
> > or something without the "." in it.
> >
> > Larry
> >
> >
> > On 8/28/06, Scott Warner <swarner@adcc.com> wrote:
> >>
> >> Thanks for looking at this.  I modified your test to show you what I am
> >> doing that is breaking.
> >> This test passes in 2.1.7 and breaks in 2.2.0.
> >>
> >> Scott Warner
> >>
> >> ===============================================================
> >> <?xml version="1.0" encoding="UTF-8" ?>
> >> <!DOCTYPE sqlMapConfig PUBLIC
> >>     "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
> >>     "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
> >> <sqlMapConfig>
> >>     <properties resource="SqlMapConfig.properties"/>
> >>     <settings useStatementNamespaces="true"/>
> >>     <transactionManager type="JDBC" commitRequired="false">
> >>         <dataSource type="${dataSourceType}">
> >>             <property name="JDBC.Driver" value="${driver}"/>
> >>             <property name="JDBC.ConnectionURL" value="${url}"/>
> >>             <property name="JDBC.Username" value="${username}"/>
> >>             <property name="JDBC.Password" value="${password}"/>
> >>         </dataSource>
> >>     </transactionManager>
> >>     <sqlMap resource="${SqlMapPath}/Include1.xml"/>
> >>     <sqlMap resource="${SqlMapPath}/Include2.xml"/>
> >> </sqlMapConfig>
> >> ===============================================================
> >> <?xml version="1.0" encoding="UTF-8" ?>
> >> <!DOCTYPE sqlMap
> >>    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
> >>    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
> >> <sqlMap namespace="Include1">
> >>      <sql id="Results.Fields">col_a, col_b</sql>
> >>         <select id="testSelect">
> >>             select <include refid="Results.Fields" /> from include1_test
> >>     </select>
> >> </sqlMap>
> >> ===============================================================
> >> <?xml version="1.0" encoding="UTF-8" ?>
> >> <!DOCTYPE sqlMap
> >>    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
> >>    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
> >> <sqlMap namespace="Include2">
> >>  <sql id="Results.Fields">col_1, col_2</sql>
> >>  <select id="testSelect">
> >>      select <include refid="Results.Fields" /> from include2_test
> >>  </select>
> >> </sqlMap>
> >> ===============================================================
> >>     public void testSqlFragments() {
> >>         String smc = "SqlMapConfig_namespace.xml";
> >>         SqlMapClient client = null;
> >>         try {
> >>             client = SqlMapClientBuilder.buildSqlMapClient(Resources
> >>                     .getResourceAsReader(smc));
> >>             assertNotNull(client);
> >>             SqlMapClientImpl clientImpl = (SqlMapClientImpl) client;
> >>             SqlMapExecutorDelegate delegate = clientImpl.delegate;
> >>             assertNotNull(delegate);
> >>             assertEquals("select col_a, col_b from include1_test",
> >> delegate
> >>
> >> .getMappedStatement("Include1.testSelect").getSql().getSql(
> >>                             null, null).trim());
> >>             assertEquals("select col_1, col_2 from include2_test",
> >> delegate
> >>
> >> .getMappedStatement("Include2.testSelect").getSql().getSql(
> >>                             null, null).trim());
> >>         } catch (Exception e) {
> >>             System.out.println(e.getLocalizedMessage());
> >>             e.printStackTrace();
> >>             fail(e.getLocalizedMessage());
> >>         }
> >>     }
> >>
> >>
> >
>
>

Mime
View raw message