Announcement Announcement Module
Collapse
No announcement yet.
Using Ibatis in WSAD Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Ibatis in WSAD

    Hi,
    1)Has anybody used Ibatis on WSAD 5.1 (WebSphere Studio Application Developer)? I have downloaded and used Ibatis on Eclipse and it works fine. Though WSAD works on Eclipse technology am not able to execute even a simple example using Ibatis.

    2) I would like to know how to use the 'LIKE' clause in the SQL Maps for Ibatis.

    Priya.
    Last edited by priyas144; Jul 31st, 2007, 11:06 AM.

  • #2
    config example

    hello,
    i use : WSAD Adv. Ed. (the one with UML) based on Eclipse 3.0.
    Spring 2.0, iBatis 2.2.0.638, iSeries v5r3, UDB2, JTOpen 5.1.1, etc...

    below is just to retrieve a list of clientName/clientID

    in applicationContext.xml :
    Code:
    	<bean id="dataSourceTarget" class="com.ibm.as400.access.AS400JDBCDataSource" destroy-method="close">
    		<!-- attention : ne pas laisser d'espaces entre les deux balises <value> de l'url  --> 
    	<property name="serverName">
    			<value>xxxxxxxx</value>
    		</property>
    		<property name="user">
    			<value>wwwwwww</value>
    		</property>
    		<property name="password">
    			<value>zzzzzzzzzzz</value>
    		</property>
    	</bean>
    
    	<bean id="sqlMapClient"
    		class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    		<property name="dataSource">
    			<ref local="dataSourceTarget" />
    		</property>
    		<property name="configLocation">
    			<!-- <value>/WEB-INF/sqlMap-config-db2-test.xml</value> -->
    			<value>/WEB-INF/sqlMap-config-db2.xml</value>
    		</property>
    	</bean>
    	<bean id="dao" class="com.stihl.intra.fpspring.dao.DAOImplDB2">
    		<property name="sqlMapClient">
    			<ref local="sqlMapClient" />
    		</property>
    	</bean>
    	<bean id="transactionManager"	class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    		<property name="dataSource">
    			<ref local="dataSourceTarget" />
    		</property>
    	</bean>
    	<bean id="service" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager">
    			<ref local="transactionManager" />
    		</property>
    		<property name="target">
    			<bean	class="com.stihl.intra.fpspring.service.ServiceImpl">
    				<property name="dao">
    					<ref local="dao" />
    				</property>
    			</bean>
    		</property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    				<prop key="save*">PROPAGATION_REQUIRES_NEW</prop>
    				<prop key="delete*">PROPAGATION_REQUIRED</prop>
    			</props>
    		</property>
    	</bean>
    in sqlMap-client.xml :
    Code:
    	<resultMap id="clientListMap" class="ClientClass">
    		<result property="header.codeClient" 	column="ATABCD"/>
    		<result property="header.name" 			column="ATBVTX"/>
    	</resultMap>
    	<select id="clientGetAll" resultMap="clientListMap" resultSetType="FORWARD_ONLY" >
    		select ATABCD, ATBVTX 
    		from stihldatf.scmdatp
    	</select>
    in sqlMap-config-db2.xml:
    Code:
    <sqlMapConfig>
    
    	<settings 	cacheModelsEnabled="true" 
    				lazyLoadingEnabled="false" 
    				enhancementEnabled="true" 
    				maxSessions="64" 
    				maxTransactions="8" 
    				maxRequests="128" />
     <sqlMap resource="/WEB-INF/sqlMap-client.xml" />
    	<sqlMap resource="/WEB-INF/sqlMap-divers.xml" />
    
    </sqlMapConfig>
    in public class DAOImpl extends SqlMapClientDaoSupport implements IDAO:
    Code:
    	public Collection getAll()
    	{
    		return getSqlMapClientTemplate().queryForList("clientGetAll", null);
    	}
    hope this helps
    Last edited by doodoonn; Aug 7th, 2007, 08:42 AM.

    Comment


    • #3
      hey buddy thnx... had to correct the appcontext xml.

      any ideas how to use the like clause in the sqlMap. have tried all sorts ofsolutiond but in vain...

      Priya

      Comment


      • #4
        LIKE in sqlMap

        ok, i've written this in one of my sql script :
        Code:
        ...
        and (trim(JDACCD) like '1%' or trim(JDACCD) like '2%' or trim(JDACCD) like '3%' or trim(JDACCD) like '4%')
        ...
        It is in my sqlMap-client.xml (see above) and it's following the DB2 SQL syntax...
        Code:
        %
        is the generic caracter 1% means "beginning with '1'"
        so, it could be different to your DB server.

        Comment


        • #5
          thnx dude... was trying the following

          like '%'+#EMPID#+'%'

          so just added the '%' on either side of the string to search and passed as a parameter.

          thnx once again....

          Comment

          Working...
          X