Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Any JSP + Hibernate examples?  RSS feed

 
Pat Perkins
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can someone point me to any JSP example code that uses Hibernate for database access? (and please don't point me to something that uses Struts - I've found enough of those). I can't seem to find any out there, any help would be appreciated.

Pat
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be honest, I'd steer away from anything that mixes Hibernate with JSP. A properly constructed web application should sequester all database access in its model layer, which should be completely UI-agnostic.

Your model layer should be usable from a Swing app, a web app, or even a command line app. If you are mixing servlets/JSP and database access in the UI layer, you're not following modern best-accepted practices.
[ July 13, 2007: Message edited by: Bear Bibeault ]
 
Pat Perkins
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, sure, that's what MVC is all about - it would be silly to do DB access from the presentation layer.

I should have been more careful and asked if anyone had a pointer to any examples that used Hibernate in a web application that also makes use of JSP for the presentation, instead of all the Struts and/or EJB junk that seems to accompany all the examples I've found so far.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Understood. But my point, which I may have made badly, is that the interface to the model should be completely transparent as to whether the Model is using Hibernate, iBatis, Jenny, striaght JDBC, or Fred's Fabulous Database Engine.

So there's no need to look for a tutorial that specifically uses JSP and Hibernate, because any touted as such would probably be violating the precept of MVC just because its about both technologies, which should be independent.

If it's the JSP side of things you're needing help with, look for a good modern JSP tutorial (good luck, I haven't found one yet). If it's Hibernate, look for a good Hibernate tutorial.
 
Pat Perkins
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I guess I was looking for something too specific, but I really had thought that using Hibernate and JSP together would be a common thing and something that a lot of people would have done, and therefore there would be a good chance one of them might have written something about it.

Not finding anything also led me to question, 'Hmm, maybe it is stupid to use Hibernate in a simple JSP-based web app since apparently nobody else is doing it.' Anyway, apparently I was just looking for an over-simple answer, will have to just go and try it myself.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pat Perkins:
'Hmm, maybe it is stupid to use Hibernate in a simple JSP-based web app since apparently nobody else is doing it.'.


Invalid conclusion.

I've used Hibernate for a few JSP-based web applications. But you'd never know it. Which is again, my point. The facts that I used JSP for the front end, and Hibernate for the backend, are completely unrelated and irrelevant.

I could switch any of these apps to use another DB engine (and probably will at some point, not a big fan of Hibernate) without touching a character of the UI code.
 
Pat Perkins
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:

I could switch any of these apps to use another DB engine (and probably will at some point, not a big fan of Hibernate)


Care to elaborate? e.g. what you don't like about Hibernate and especially any alternatives you could suggest.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!