[英]Java + Spring + hibernate : Dao implementation that is about to change in the future
I'm currently developing a web server with spring 3 and hibernate 4. 我目前正在使用Spring 3和Hibernate 4开发Web服务器。
in my server i have the following interfaces: 在我的服务器中,我具有以下接口:
and 3 implementations: 和3种实现:
In the future we are considering very highly to migrate to a NO-SQL db (maybe couchDB). 将来,我们将高度考虑迁移到NO-SQL数据库(也许是ouchDB)。 My questions is:
我的问题是:
"since no-sql has nothing to do with orm, will i need to actually replace all the daos impl in my project?! (there could be alot) isn't there a more generic way?" “由于no-sql与orm无关,所以我是否需要替换项目中的所有dao ??(可能很多)是不是有一种更通用的方法?”
thanks! 谢谢!
What about using JPARepository : look at http://www.springsource.org/spring-data/jpa 关于使用JPARepository呢?请看http://www.springsource.org/spring-data/jpa
CrudRepository are very usefull and save a lot of time. CrudRepository非常有用,可以节省大量时间。 Look at the jpa-spring documentation too You define a sub-interface of CrudRepository for store entity class objects.
还要查看jpa-spring文档。您为商店实体类对象定义CrudRepository的子接口。 CrudRepository define for you the crud service And you can add in your interface a method like "findTicketByExpireDateBefore(Date date)" then spring will use the naming convention to build the implentation of the requete If the requete is more complexe you can use the @Query annotation to write it
CrudRepository为您定义Crud服务,您可以在界面中添加“ findTicketByExpireDateBefore(Date date)”之类的方法,然后spring将使用命名约定来构建请求的实现。如果请求更复杂,则可以使用@Query注释写
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.