0

how to integrate zk framework with spring & hibernate, it's possible ?

asked 2012-09-12 01:41:36 +0800

progamerdotcom gravatar image progamerdotcom
117 5

Good morning all,

I want to integrate zk to other framework such as spring and hibernate.

Are you ever to do it ? , if you do, please point me some tutorial about these integration.

Thank a lot.

Regard,

Pro G.

delete flag offensive retag edit

12 Replies

Sort by ยป oldest newest

answered 2012-09-12 11:13:50 +0800

blacksensei gravatar image blacksensei
234 2

updated 2012-09-12 11:14:27 +0800

Yes it's possible with ZK 5.0.x . I use hibernate annotation with either with entityManager or session. I use spring to have cute url eg. http://localhost:8080/zktest/index instead of http://localhost:8080/zktest/index.zul . so there is no Spring MVC controller, i still use ZK MVC Controller which is actually wired by spring with the prototype scope. on the mapping to the view i use <mvc:view-controller in spring applicationcontext.

Now with the ZK 6 it seems not to be working. i posted on this forum but it seems it hasn't interested anybody yet :(

link publish delete flag offensive edit

answered 2012-09-19 04:15:29 +0800

MontyPan gravatar image MontyPan
435 3
http://xitop.blogspot.com...

Hi progamerdotcom,

Integrate Hibernate to ZK works fine.
The goals of these two framework is different, use Hibernate to operate database, use ZK to handle user action and present data,
they are independent.

There is another reference about Use CDI in ZK:
http://books.zkoss.org/wiki/Small_Talks/2012/September/Practices_Of_Using_CDI_In_ZK

Regards,
Monty Pan

link publish delete flag offensive edit

answered 2012-09-25 04:18:35 +0800

progamerdotcom gravatar image progamerdotcom
117 5

Hi MontyPan,, thank for your advice ,,

:)

link publish delete flag offensive edit

answered 2012-10-04 14:55:25 +0800

aros54 gravatar image aros54
66

In my experience there is no problem to integrate ZK, Spring and Hibernate as well as many other tools and frameworks available in the J2EE world. However, as there are some overlapped areas, the key of success is to choose the rigth tool to perform the thing it does better and, of course, be careful on choosing the compatible software versions.
Hibernate is an ORM tool, very good to free your application code from the DBMS used. ZK is typically used to manage the view part of the application, although it can be helpful on writing the controller functionalities too. Spring framework does a lot of things. A feature that cannot be renounced is the IoC container. Also Spring security module is a good choice.
Everyone of these tools do much more than what I said. It is important that you carve out your way to use each tool for every specific usage and how they couple together. For instance, Spring has a native integration with the data access made through Hibernate while ZK provides an integration library with Spring, etc.
I have a pretty long experience of projects made using this technology. If you have any particular question about it or need help on specific architectural problems feel free to contact me directly at this mailbox whoa4999 AT gmail DOT com.
/Adriano

link publish delete flag offensive edit

answered 2012-10-05 01:27:16 +0800

progamerdotcom gravatar image progamerdotcom
117 5

Thank Adriano,

I already begin zk with hibernate and spring integration, it's OK,

but I have some problems, how to inject a DAO from other DAO,

for example I have patientDaoImpl that must inject doctorDao,


public void saveTreatment(Patient patien){
  //Here I want to inject doctorDao
}

Thanks for sharing

link publish delete flag offensive edit

answered 2012-10-05 08:22:48 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

have a look at the codes and configuration files from the Zksample2 backend sub project.

best
Stephan

link publish delete flag offensive edit

answered 2012-10-05 08:58:10 +0800

aros54 gravatar image aros54
66

If you google around you can find a lot of code sample about Dao injection. Zksample2 is a good place. I would add that object injection is Spring's know-how. So look at Spring code samples to understand this matter.
Anyway, just to say one word about your question, in my opinion you shouldn't inject a Dao with another Dao. A Dao object is a Data Access Object, specialized to access one and only one data object. You have one Dao for Patient entity and another Dao for Doctor entity as well as their daoImpl actual implementation. What you are trying to do - that is the union of several Daos to perform a complex data access - should be done using a Service interface. The method saveTreatment is a method of HospitalService interface, whose HospitaleServiceImpl actual implementation can be injected with patientDao, doctorDao, nurseDao, medicineDao, etc.
Spring bibliografy is full of these expamples.
/Adriano

link publish delete flag offensive edit

answered 2012-10-05 14:23:10 +0800

progamerdotcom gravatar image progamerdotcom
117 5

Thank Stephan and Adriano,, zksample with new documentation, last update Oct 05, 2012

double thanks masters

link publish delete flag offensive edit

answered 2012-10-05 15:31:48 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

:-) Yeah, i have update a little bit about spring scopes. I have had a problem for getting a controller.
After a few tries i remember for the ultimate weapon. the EventQueue as a global listener helped me to call methods from everywhere in the application.

best
Stephan

link publish delete flag offensive edit

answered 2012-10-05 23:59:18 +0800

progamerdotcom gravatar image progamerdotcom
117 5

yes Sir :-) ,, I am new in ZK, I will learn Zksample2,, I already checkout zksample2 in my eclipse but its in one project, I confused how to run it, 4 projects in a zksample2 project bundle and I read your documentation, try to run zksample, http;//localhost:8080/ ,, wheres the path to access main index zksample2, ( zkoss project as frontend).

Thanks Sir.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-09-12 01:41:36 +0800

Seen: 316 times

Last updated: Oct 08 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More