-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Using POJOs as DTO in Client/Server Applications
PostPosted: Wed Aug 18, 2004 8:46 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
Hello,
I have a server (Session EJB deployed under JBoss) with Hibernate based persistence of my POJOs and the need to use the same POJOs to communicate with the remote clients (swing and web apps).

The problem is in collections, Hibernate use (for well documented reasons) his implementations but I can't use Hibernate libraries in my clients, I can include only the POJOs classes.

How can I resolve this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 10:06 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
copying your pojo into dto without depedencies to hibernate packages

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 11:09 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
As explained in Hibernate in Action, chapter 8, I prefer to avoid DTO and send to the client my POJOs (they are also my model business objects) without maintaining 2 classes trees and without translating POJOs into DTO and vice versa every time.

There is another solution? The collections will be always recreated in the DB?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 11:21 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Hibernate will be able to track changes to your collections if you remove the proxy wrappers (which would be possible using custom serialization), so yes, that means that they might get saved and/or update when you don't want it. However, there is saveOrUpdateCopy(), which you might find interesting. You are on a difficult path, though.

If your swing client is not distributed over a slow network (that means, it is a local install, once), why not include the Hibernate library? If you read the appendix in HiA, you will see that this is exactly one of the FAQs answered there.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 11:22 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
will NOT be able

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 11:50 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
Thank you very much for the clarification

christian wrote:
If your swing client is not distributed over a slow network (that means, it is a local install, once), why not include the Hibernate library?


This is a design decision, not a network limit.
We have many different clients in different locations, a change in the persistence engine (eg. an upgrading from a new version of Hibernate with a different implementation of collections) will require an update in all client installations.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 4:03 pm 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
I agree with Teg, this is an unavoidable consequence to having chosen more expressive thick remote clients over more accessible thin local (reas same VM) clients.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 4:05 pm 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
(didn't complete post above)

... however, some might argue Web Start and other technologies can aid in this arena. That is another can of worms...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 3:49 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
Web Start is nice for some swing applications but how to update other clients as web apps or client libraries used by other software?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 6:35 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Teg wrote:
Web Start is nice for some swing applications but how to update other clients as web apps or client libraries used by other software?


Connect directly to database from app, it will solve many problems and there is nothing wrong in this deployment.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 7:04 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
baliukas wrote:
Connect directly to database from app, it will solve many problems and there is nothing wrong in this deployment.


Only in a single user application or in a simple web app you can use direct connection to DB.
I think that when you have a complex business with multi user environment and many clients (only presentation tier or library) is wrong to have clients directly connected to DB.
Security and data management must be centralized.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 8:24 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Teg wrote:
I think that when you have a complex business with multi user environment and many clients (only presentation tier or library) is wrong to have clients directly connected to DB.

Many people think it is wrong, but nobody can explain why it is wrong.
App server vendors and marketing make you think this way (They can not sell RDBMS anymore so they are trieng to sell app server for you).

Quote:
Security and data management must be centralized.


Yes, you are right, it must be centralized in DB, you pay money for this RDBMS feature too.

Sorry for political post, but I think it is true.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 8:48 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
I agree with you if the logic, validation, security etc. will be into the DBMS, but if you design a DBMS centric application then you lose all the benefits of java and you become tied to a specific DBMS.

I prefer a java centric application for obvious rasons


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 9:57 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Most "complex" applications with workarounds for performance are tied to a specific DBMS any way and it is possible to use opensource RDBMS for this reason. JAVA is not the only language in the world too, there are many good tools for RDBMS like reporting frameworks and probably it is more dangerous to be tied to JAVA than to RDBMS, you can not make people to use JAVA for all use cases in the "complex business with multi user environment " system.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 10:40 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
Quote:
you can not make people to use JAVA for all use cases in the "complex business with multi user environment " system.


Other people can choose DBMS centric application, but this is not the case.
My problem is to send objects to remote clients without Hibernate libraries in the simplest way.

From online reference:
Quote:
Hibernate may not be the best solution for data-centric applications that only use stored-procedures to implement the business logic in the database
[/quote]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.