-->
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.  [ 3 posts ] 
Author Message
 Post subject: Blown away by Hibernate
PostPosted: Tue Oct 25, 2005 4:55 pm 
Beginner
Beginner

Joined: Sat Oct 22, 2005 11:16 pm
Posts: 40
I don't really have anything to say in this post other than that I'm blown away by Hibernate. I'll never be able to go back to using JDBC for anything but the most simple batch processing tasks.

I have just put together a servlet which uses introspection to look at classes, then decide which servlet request parameters it needs, then pass those parameters to the object, which then validates them, and then Hibernate stores the whole thing. So all of my business logic (including validating user input) is all within the business object where it belongs. I don't need to write a new servlet for every business class; introspection lets one servlet do all the work. And I don't need to write any SQL to store and retrieve them; Hibernate takes care of all of it. And I don't have to worry about SQL injection. On the topic of SQL injection, I'm pretty convinced that most PHP / MySQL sites out there are at least somewhat vulnerable to SQL injection. I assume that with Hibernate SQL injection is impossible.

Anyway, it's an amazing system and (with my new introspection servlet) it lets me spend 80% of my time and effort writing business objects, instead of spending 80% of my effort dealing with SQL, servlets, etc.


Top
 Profile  
 
 Post subject: additions :)
PostPosted: Tue Oct 25, 2005 5:32 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
I suggest adding Tapestry (I think it will blow you away too) to the mix and letting Servlet filter to take care of Hibernate session management.

http://www.hibernate.org/43.html#A3
http://www.hibernate.org/42.html

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject: Re: additions :)
PostPosted: Tue Oct 25, 2005 11:16 pm 
Beginner
Beginner

Joined: Sat Oct 22, 2005 11:16 pm
Posts: 40
kgignatyev wrote:
I suggest adding Tapestry (I think it will blow you away too) to the mix and letting Servlet filter to take care of Hibernate session management.


I'll look into it.

Now I have changed it so that I have some custom annotations, so in my business classes, I can note things like "instances of this class should be unique" and then I can note properties as being parts of the business key. Then my Servlet introspects those objects and does a query to make sure that the object is unique before it is saved. Somehow once I get all these tools (Hibernate, introspection, annotations) working together I'll finally be exactly where I want, which is I write zero SQL, few servlets, and most of my time is writing business objects the way I want them. This will be an amazing enhancement, because before I would spend most of my time dealing with servlets.

Now the remaining thing I have to figure out is this:

If there is a unique constraint on my class, what I do is I make up a "test instance" and do a query-by-example to see if there is a match. However, before I do that I also make up a PropertySelector so that only business keys (which I got from reading annotations) are compared. That's all great, except that one of the business keys is not a property, but rather an association. In my particular case, I'm creating a system where users can manage a calendar. Of course they put things into Categories, and of course Category should be unique for every user. QBE doesn't work because User isn't a property of Category; User is an entity and it's connected by a many-to-one association.

So that's the next thing to figure out: how to use the annotations to define the biz key when the biz key uses associations AND properties. I think I'll have that figured out tonight.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.