View Full Version : GXT MVC and Hibernate
Hi Darrell
I'm new to GXT(MyGWT) and want to know if there is confortable way to use Hibernate on the Server Side. I don't wan't any DTO's and would like to use your MVC architecture. BaseModel is Serializable and therefore ready for data exchange between browser and server. But I don't know how to deal with your BaseModel and Hibernate (lazy loading) for GWT RPC. Additionally I'm using Seam as Server logic which is just wonderful and Hibernate is a must for the persistence.
It would be great if there is a way to combine the server side persistence (hibernate) and GXT without any DTOs
Any suggestions?
Thanks,
Lars
use hibernate4gwt (http://hibernate4gwt.sourceforge.net/)
I don't see how to bridge Entites to DataModels. In DataModel a mechanism for RPC is implemented. I can't wire these thing in my mind, not yet ;)
+1 ,
my project use pojo hibernate (with hibernate4gwt) and not DTO , with GWT-EXT , the rpc mechanismfor grid , tree , combo is not intrusive.
But , I don't understand How my Pojo can implements your ModelDate interface , is too intrusive.
zaccret
05-22-2008, 05:51 AM
I'm not sure to well understand the issue so I suppose my post won't answer your question. Anyway, the subject (Ext GWT-Hibernate integration) is really interesting so here is my question : why not working with ModelDatas wrapping your POJOs instead of implementing ModelData, like this :
model.set("pojo",pojo);or maybe you can write your own model wrapper :
public class WrappedBaseModel<Model> extends BaseModel {
private final Model data;
public NestedBaseModel(Model data){
super();
this.data = data;
}
public Model getData() {
return data;
}
}
zaccret
05-23-2008, 10:01 AM
Sorry for my stupid answer :">, you simply cannot do that if your pojo object is not in the GWT source path. By the way, I've posted a new thread for larger discussion (not only Hibernate) here : http://extjs.com/forum/showthread.php?p=172357.
Grandiosa
05-23-2008, 10:45 AM
you simply cannot do that if your pojo object is not in the GWT source pathI believe you can get around that by creating a simple GWT dummy module in the top level folder of your project. The module should just use the source tag to point to your pojo directory. Then any GWT module located beneath that directory can get access to the pojos by just inheriting the dummy module. For example, if your pojos are in a top level domain folder, create a dummy module with this content.
<module>
<source path="domain"/>
</module>
zaccret
05-28-2008, 11:54 AM
I believe you can get around that by creating a simple GWT dummy module in the top level folder of your project. The module should just use the source tag to point to your pojo directory. Then any GWT module located beneath that directory can get access to the pojos by just inheriting the dummy module. For example, if your pojos are in a top level domain folder, create a dummy module with this content.
<module>
<source path="domain"/>
</module>
Have you managed to do that ? I fail. Even if I succeed, some of my domain objects depend on other libraries and I don't want to put all my dependencies in the source path.
Grandiosa
05-29-2008, 04:41 AM
Have you managed to do that ?Yes. But my case is simple because my business logic is in db, so my "domain" objects aren't really domain objects, they're simply DTOs based on ExtGWT Model objects. My Spring JDBC driven DAOs return ExtGWT based DTOs directly, and my GWT service calls just passes them back to the client as is. Then my Ext GWT Controller installs ChangeListeners on them.
In my toplevel source directory I have this module file to make sure my domain (dto) objects can be sent over RPC.
<module>
<source path="domain"/>
<inherits name='com.extjs.gxt.ui.GXT'/>
</module>
Even if I succeed, some of my domain objects depend on other libraries and I don't want to put all my dependencies in the source path.
Fair enough, and that will probably be the case for all but the simplest domain models (like mine). Such apps must convert the domain objects to RPC'able DTOs. If you're doing this conversion yourself you might as well create ExtGWT Model objects directly in your GWT service.
But if you're using something like Dozer or hibernate4gwt to convert your ORM based domain objects to RPC'able DTOs then you have two options. You either do another conversion to ExtGWT Model objects in your service (ugh..), or you might choose to do the conversion to ExtGWT model objects in the GWT client instead, e.g. in the ExtGWT controller which has the callback for your RPC call.
I think if I was using Hibernate with a Ext GWT front end I would seriously consider writing my domain2dto converters myself to avoid the extra step via POJOs, which aren't really usable in ExtGWT.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.