Is it OK to use both JPA (for normal CRUDs) and JDBC (for batch update & call stored proc) in the same project

一笑奈何 提交于 2019-12-12 20:09:36

问题


I am using JPA/Hibernate to call simple CRUD queries (create, update, findByXAndYAndZ...). However, as I know, JPA doesn't support well on calling stored procedures and batch insert/update, so I consider using old JDBC to do that (like this link: http://www.java2s.com/Code/Java/Database-SQL-JDBC/BatchUpdateInsert.htm).

I just wonder if it causes any problems when I mixing JPA and JDBC. Hope that you may share some real-world experiences on this issue. Thanks.

UPDATE: I have tried the Spring Batch like suggestion of Behrang Saeedzadeh and it worked well. @Others: you may look at the example of Spring Batch here: http://mkyong.com/spring/spring-jdbctemplate-batchupdate-example


回答1:


It's OK. However you should ensure that you invalidate relevant JPA caches when you make direct JDBC batch updates.

UPDATE: By the way, you might want to consider having a look at Spring Batch. Using Spring Batch you can make batch updates with JPA or with JDBC if you prefer so.



来源:https://stackoverflow.com/questions/7199950/is-it-ok-to-use-both-jpa-for-normal-cruds-and-jdbc-for-batch-update-call-st

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!