ここで手足を出して、iBatisを検討しましたか? これは、現実的なクエリ マッピング フレームワークです (ORM フレームワークと呼ぶのはためらいがあります)。次のような XML ファイルを作成する必要があります。
<mapper namespace="org.mybatis.jpetstore.persistence.ProductMapper">
<cache />
<select id="getProduct" parameterType="string" resultType="Product">
SELECT
PRODUCTID,
NAME,
DESCN as description,
CATEGORY as categoryId
FROM PRODUCT
WHERE PRODUCTID = #{productId}
</select>
</mapper>
次のようなマッパーを配線します。
public interface ProductMapper {
Product getProduct(String productId);
}
これにより、次のようなサービスからデータにアクセスできます。
@Autowired
private ProductMapper productMapper;
public Product getProduct(String productId) {
return productMapper.getProduct(productId);
}
Springで接続できるもの:
<!-- enable autowire -->
<context:annotation-config />
<!-- enable transaction demarcation with annotations -->
<tx:annotation-driven />
<!-- define the SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="org.mybatis.jpetstore.domain" />
</bean>
<!-- scan for mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.mybatis.jpetstore.persistence" />
</bean>
完全なペットストアの例も参照してください。
私は iBatis の明確なファンではありませんが、この特定のケースではニーズに合うかもしれません。