Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

RE: While I'm choosing Hibernate over JDO ... for now

Now I will talk to you about the dealbreaker - the one thing about JDO that pushed me pretty rapidly over to the Hibernate camp: the query language. The JDO query language is just poor, very poor and of a syntax that only the designer could appreciate.

Class gameObjectClass = com.foo.GameObject.class;
Extent oldObjects = pm.getExtent (gameObjectClass, false);
String filter = "age > 25";
Query q = pm.newQuery (gameObjectClass, oldObjects, filter);
Collection oldGameObjects = q.execute ();


This unfortunately gets more and more complex as you have to introduce other variables into the query. This is a major failing of JDO IMO. Hibernate was just so much easier to deal with from the query perspective (and since that's what you'll be spending most of your time doing...).

List oldObjects = sess.find( "from obj in class com.foo.GameObjects where age > 25" );

Big difference in both presentation, LOC and generally understandability in my opinion. [Nation of Greg :: Redux]

I have to agree with Greg here. Hibernate's query language (HQL) is extremely easy to use. In fact, I've been amazed at how I've been able to guess the syntax and get it right 9 times out of 10! It's the best of SQL and OQL. If you think HQL is good - wait until you checkout the Query by Criteria syntax (very cool IMO). There's supposed to be a Hibernate 2.0 Final this weekend... only 26 hours left in my neck of the woods. will they make it?

Posted in Java at Jun 07 2003, 09:53:49 PM MDT 6 Comments
Comments:

What is this, a deliberately malicious example? :-) No, I know, it's probably how it was written in some tutorial or book. I've used some JDO, but it would be written like this:

Query query = pm.newQuery(pm.getExtent(GameObject.class, false));
query.setFilter("age > 25");
Collection oldGameObjects = (Collection) q.execute ();

That would be...3 lines.

And I know it's just that I'm no sql guru, but I find the JDO syntax a lot easier to read than "from obj in class com.foo.GameObjects where age > 25". Of course, that's what jdo is aiming for - java-like syntax, not sql-like syntax. And since I'm lazy ;-) I'd rather not learn more new syntax.

Posted by Paul Rivers on June 09, 2003 at 04:23 AM MDT #

PS

And if 25 wasn't hardcoded, you be be using name parameters for your hibernate query - in which case you would have another line or two of code, while the jdo query would stay the same size.

Posted by PaulRivers on June 09, 2003 at 04:19 PM MDT #

Sorry about this, I realized the jdo query would need one more line if the parameter wasn't hard-coded:

Query query = pm.newQuery(pm.getExtent(GameObject.class, false));
query.setFilter("age > ageParam");
query.declareParameters("int ageParam")
Collection oldGameObjects = (Collection)
q.execute(new Integer(25));

Posted by PaulRivers on June 09, 2003 at 04:32 PM MDT #

>> I realized the jdo query would need one more line if the parameter wasn't hard-coded <<

Whereas the Hibernate case would not:

List oldObjects = sess.find("from GameObjects go where go.age > ?", age, Hibernate.INTEGER);

;)

okay, if you use Hibernate named parameters, to make it a fair comparison, the Hibernate version becomes:

session.createQuery("from GameObjects go where go.age > :age").setInteger("age", age).list();

Which is still much less verbose.

Posted by Gavin on June 10, 2003 at 02:08 AM MDT #

Well, if you're going to do that, we should be counting characters instead of lines of code ;-)

Posted by Paul Rivers on June 11, 2003 at 05:53 AM MDT #

hdsgfdg

Posted by fds on April 26, 2005 at 10:34 AM MDT #

Post a Comment:
  • HTML Syntax: Allowed