Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Entire Code for j2ee Application with struts and hibernate

 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends can you give me sample code for Entire j2ee web application with struts and hibernate.I mean code for Dao, DaoImpl, HibernateDao ,HibernateDaoImpl, Dto , service , ServiceImpl , i.e.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajendra, I don't want to be rude but JavaRanch is not a code mill. What you are asking is for quite a bit of work for someone. Have you looked through the example applicaitons Struts and Hibernate offer on their sites/with their code?

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friend, . can you give the link for sample application.I have searched web application with struts and hibernate but i did not get like dao , daoimpl ,service , serviceimpl ..
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Various Hibernate example applications can be found here, there are a million and one struts examples out there, and this gives you some detail on other patterns mentioned.
 
Saloon Keeper
Posts: 21311
140
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, but there are a few cautions here. This is my Technology SandBox app, so it's where I learned how to do things. And sometimes, how NOT to do them. So it's not very pretty.

http://svn.mousetech.com/svn/jtaonthemove/trunk/jtaonthemove/src/main/java/com/mousetech/jta/persist/

I've provided the URL down into the persistency layer, which I don't organize in quite this way anymore. You can see the rest of the app by walking uphill from there. This is a Maven-built application, so it has Maven's (un)usual directory structure, plus the additional quirks from being stored in a Subversion repository.

As far as the application itself goes, there are 2 ways to handle ORM in webapps. One - very popular - way is to use a filter to ensure that the persistence manager is open and connected to all objects from the time the request arrives until the final byte of the reponse is written out (or close enough not to matter).

I consider that cheating. It allows you to make lazy fetches, but it also encourages lazy coding. So I don't use it. In consequence, all transactions are atomic at the dao/service level, and if you decide that you needed more data, you have to go back and get it. An unfortunate side-effect of that is that when you reconnect an object, it doesn't literally reconnect. It effectively creates a whole new copy of that object and returns that. This can be a real annoyance when processing objects that are in collections, as it means that the collection has to be updated as well. This app has a lot of interconnected objects fetched a lot of different ways, and some of it got pretty ugly. Such is life in the Real World when youu don't have good guidance.

I've never seen a formal definition, but my own is that a DAO is basically a "service" for interacting with a single table, and a Service is something that interacts with a set of interrelated tables. Since so much of what I do is service-related, I've pretty much abandoned straight DAOs, but there's a legacy in this sample.

As I said, this is my sandbox, so it's not as neat and tidy as an academic sample. But it's a good example of how real-world projects can be.
 
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!