Ajax in hibernate project
Has anybody used ajax in hibernate p开发者_StackOverflow中文版roject ? Any pointers, help will be appreciated.
You might be referring to the open session in view problem, but your question is a bit too minimal at this point.
As for me: Yes I have used Ajax & Hibernate in the same project using Wicket, and I haven't run into any problems (when taking the above into account).
AJAX and Hibernate are not related almost at all. They might become partially related in the context of one framework or another. The flow would look like that:
Hibernate (fetches entities) -> service layer (manipulates the result) -> controller (serializes the objects to xml/json/whatever) -> ajax (displays the result dynamically)
You see, there are many steps between hibernate and ajax. You will eventually bump into a problem, which was already mentioned and is solved by the open-session-in-view
.
We use both every day.
However, the two technologies are not related, they don't interact.
So there is nothing specific, you can just use each... ;-)
Your question is too generic as you have not included information about what exactly you are having a problem with.
So based on my understanding, I will give you a brief of what each of these technologies does and how are they related:
Consider a website which allows you to retrieve and persist employee details to a database from your web browser. The way browser communicates to your server will be AJAX (If you do not know what is AJAX, I'd suggest you to read more and enlighten yourself on it).
Now, the AJAX-based request has reached your server, which will employee another Java technology called a "Web service" which will receive this data and based on business logic, it will decide whether to query the DB and what to query it for.
Every database will implement different flavors for SQL, so you cannot change keep changing your project's core for every database. So we use Hibernate to provide an fuss-free, direct communication layer to different types of databases at once. All you now need to change when migrating form one database to another is your connection string and the driver you are using (both in a hibernate configuration file - hibernate.cfg.xml).
精彩评论