如何在java中集成hibernate和REST Web服务? [英] How do I integrate hibernate and REST web service in java?

查看:101
本文介绍了如何在java中集成hibernate和REST Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将开发哪些将是web应用程序以及移动(android / iOS / windows)应用程序。此应用程序中的数据库将由Hibernate管理。此外,由于它是跨平台应用程序,因此也将使用Web服务。到目前为止我所知道的是:



HIBERNATE:

*) POJO文件(将创建数据库表的getter-setter)

*)模型(将与数据库交互的java类)

< b> *)控制器(基本上是servlet,它将从view [jsp]获取数据,在POJO对象中设置它并将此对象传递给Model进行任何CRUD操作)

*)查看(jsp页面)



REST WEB服务:

*) Web服务实现类,它具有Web方法,可以通过客户端的URL调用,并且可以返回JSON或XML格式数据。



所以现在我的问题是:

*)如何整合这两者?我应该将我的所有POJO和模型文件都放到Web服务中吗?如果不是,那么在这种情况下该做什么?如果是,那该怎么做(简单的例子)?



我尝试过的事情:



我曾尝试单独使用Hibernate和REST Web服务,但不能一起使用。我不知道怎么做。

解决方案

你试过google吗



Spring 4 Restful Web Services with Hibernate 4使用Maven&#8211;服务器应用| Beingjavaguys.com [ ^ ]

I am going to develop which will be web application as well as mobile (android / iOS / windows) application. The database in this application will be managed by Hibernate. Also as it is cross platform application, web service will also be used. What I know so far is:

HIBERNATE:
*) POJO Files (the getter-setter ones which will create database tables)
*) Model (the java class which will interact with database)
*) Controller (basically servlet which will get data from view [jsp], set it in POJO object and pass this object to Model for any of CRUD operation)
*) View (the jsp pages)

REST WEB SERVICE:
*) Web service implementation class, which have web methods, which can be called by URL from client, and it can return JSON or XML format data.

So now my question is:
*) How to integrate these both? Should I put my all POJOs and Model files to web service? If no, than what to do in this situation? If yes, than how to do that (simple example)?

What I have tried:

I have tried using Hibernate and REST web services separately, but not together. And I have no clue how to do that.

解决方案

Have you tried google it

Spring 4 Restful Web Services With Hibernate 4 Example using Maven &#8211; Server Application | Beingjavaguys.com[^]


这篇关于如何在java中集成hibernate和REST Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆