Note: Eclipse rap rich client Development Summary-a series of articles are transplanted from my iteye blog. Later will directly update the http://jlins.iteye.com/
1. Integrate RCP/RAP with spring
Activator is the class to be loaded when RCP/RAP is started. It only needs to be loaded once. Therefore, during integration with spring, spring's applicationcontext is usually loaded in this class.
The details are as follows:
Add the following code to Activator:
PrivateApplicationcontext context;
This. Context = new classpathxmlapplicationcontext ("config/aplicationcontext. xml ");
Load the following information in common. xml:
1.1 load data sources
Example:
<bean id="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource"><property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property><property name="url" value="jdbc:oracle:thin:@xx.xx.xx.xx:xxxxxx"></property><property name="username" value="xxxx"></property><property name="password" value="xxxx"></property></bean>
1.2 load the sqlmapconfig of ibatis
Example:
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"><property name="dataSource" ref="dataSource"></property><property name="configLocation" value="sqlMapConfig.xml"></property></bean>
1.3 load database-related categories or configuration files: connect to the database, close the database, release the resultset, add, delete, modify, and query the database
Example:
<Bean id = "eeedao" class = "com. july. dao. xxxdao "> <property name =" sqlmapclient "ref =" sqlmapclient "> </property> </bean> introduce some specific configuration files <import resource =" xxx/xxx. XML "/>
2. Integrate RCP/RAP with ibatis
This object is the interface for ibatis to operate databases (perform crud and other operations). It can also perform transaction management and other operations. This class is the most important class we use ibatis. It is thread-safe. Generally, it is defined as a singleton. (Similar to the sessionfactory definition in hibernate)
Sqlmapclient provides the following functions:
Explicitly call transactions.
Perform regular operations on the database.
Batch process non-query SQL statements.
<Sqlmapconfig> <sqlmap resource = "XXX. xml"/> </sqlmapconfig> XXXXXXX. xml defines the addition, deletion, modification, and query operations for some databases, as shown in: <? XML version = "1.0" encoding = "UTF-8"?> <! Doctype sqlmappublic "-// ibatis.com//dtd SQL map 2.0 // en" "http://www.ibatis.com/dtd/sql-map-2.dtd"> <sqlmap namespace = "people"> <typealias alias = "person" type = "person"/> <update id = "updatenamebyid" parameterclass = "person"> updatepersonset name = # name # Where id = # ID # </update> </sqlmap>
Special: If the input parameter is a variable, for example, in the following case, you need to query a sequence in the database, but the sequence name is not a constant, but a variable, at this time, you cannot add the # symbol before and after, but use the $ symbol.
<select id="getSequenceValue" resultMap="allResultMap"><![CDATA[select $seqName$.NEXTVAL||'' sequenceid from dual ]]></select>