Struts -> Hibernate
Hi,
I am currently working on a small (for me quite large) project with Struts.
Some basic Information
I am quite new to J2ee applications but decided to work with Struts, because there are more references of tutorials and I have little experience in it.
For O/R mapping I use Hibernate.
Now my Question:
I represent my tables (stored in a MySQL database) as POJO and call them Business Objects (I am following the pattern, supposed in the book "Programmin Jakarta Struts").
Anyway, I do not intend to send this BOs to the action since they often contain a lot of data I won't use.
Therefore I planned to create single ValueObjects which is created by a ServiceInterface and which would contain, for example a person's name and sirname.
If I need a more detail description I' will create another ValueObject wich extends the person's "BasicView" to a detail view.
But the detail view is actually (in my app) nothing but the BO itself rewritten in another class.
So I don't know if its a good approach.
But therefore I am asking some experts, namely you!
Any help would be appreciated
Peter
Message was edited by:
Peterson
[1231 byte] By [
Petersona] at [2007-10-3 1:12:11]

Okay, now I have done some research.
So far I do not know how big my application will become. But I definitely know that I will use Hibernate and Struts.
The Question is (now short):
Is it a better approach to start accessing Hibernate from the Action Controllers or implement a "Service-Interface" in order to be more independent und use DTO even though they are very similar to my actual Business Objects.
Thanks,
Peter
> Okay, thank you
>
> So I will stick on my concept and I won't need a
> ServletFilter for Hibernate sessions :-)
God no. Why should the servlet know or care that you're using Hibernate?
Only put the code you need to handle the HTTP request and response in the servlet or Action. Let the work be done elsewhere. It'll be easier to test, and you can still call it outside Struts.
Put it all in a servlet or Action and there it'll stay.
%
> I am quite new to J2ee applications but decided to
> work with Struts, because there are more references
> of tutorials and I have little experience in it.
If you are new to J2EE, then avoid Struts and Hibernate AT ALL COSTS! They are horrible to work with and only cause pain, ESPECIALLY if you're doing a small project. Struts/Hibernate are buzzwords and everyone rushes in to use them, but mark my words, if you go down that path it will take you twice as long to code your app.