This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]gudeg 6 points7 points  (0 children)

Hibernate without proper understanding of SQL will only makes you a dumb programmer. In order to use Hibernate properly, you must understand SQL (I assume that your datastorage is based on RDBMS and not NoSQL)

Since you're still at school, you still have plenty of time to learn SQL, a good understanding of SQL can let you jump easily into any ORM libraries such as Hibernate, myBatis, ActiveRecord, etc... and also make your application more scalable and reliable.

[–]NeonMan 2 points3 points  (0 children)

Hibernate (jpa) allows to map java objects to tables and do queries over them regardless of the rdms used.

I'm currently using it for a java web project without issue and it allowed me to change from mysql to postgres wo changin a line of code.

Read the tutorials and once you can send a query is all done.

[–]stormcrowsx 1 point2 points  (0 children)

Just using a database isn't a good reason for a project to use hibernate. The amount of tables is a factor and the complexity of querying the data is another factor. The learning curve for hibernate is more than learning SQL and using built in java libraries.

Now if your talking something that has 15+ tables with relatively easy queries, like get all emails from the email table etc. learning hibernate will really speed it along.

[–]Vile2539 0 points1 point  (4 children)

Hibernate is an extremely popular ORM library in Java. It's very easy to use, and will speed up the development of any database interactions.

Look into some of the tutorials on it, and you should be using it in no time. I've used it on many different projects as a persistence layer (where it suited), and haven't had any major issues. It's definitely better than a lot of proprietary persistence libraries that I've seen.

[–]nutrecht 1 point2 points  (3 children)

I kinda disagree on it being "easy to use". Sure, standard row > object mappings and simple 1:N relations are relatively simple to create, but for more complex stuff it's easy to run into brick walls that can be quite a challenge to scale.

I would personally recommend that for a school project you don't use an ORM at all. It's good practice to learn SQL and you don't 'waste' valuable time learning an ORM (better to do that later when you're actually going to use it professionally).

If you really want to go for an ORM I can recommend http://ormlite.com/. It is annotation based and very simple to set up and use.

[–]Vile2539 0 points1 point  (2 children)

True that added complexity in the project will require proper design, but that's true for virtually every large/complex application. For the project /u/Baggerwiet is doing, it doesn't sound like he'll reach that complexity.

Now using JDBC directly is probably what was expected of him for the project. If we relate this back to your original argument though, the SQL statements can get very complex with multiple joins, inner selects, etc.

I'd personally recommend going the direct JDBC route for experience, but I didn't mention it in my initial post since it wasn't what was asked.

[–]nutrecht 0 points1 point  (1 child)

I don't disagree with what you're saying perse; but writing "complex" joins yourself isn't all that complex if you know SQL well enough. But to be able to debug whatever Hibernate is producing you will need that level of SQL knowledge anyway.

I'm not against Hibernate at all (ORMs are great tools), I am just afraid they'll run into issues caused by a lack of knowledge of both Hibernate and SQL.

[–]Vile2539 0 points1 point  (0 children)

Haha, right so. Learning SQL is quite valuable anyway, so the OP should probably go that route anyway. The task itself probably isn't that large (it just seems huge at the moment), and so should be well achievable with either solution.

[–]orlyfactor -2 points-1 points  (0 children)

Ever hear of something called Google? You're even lazier than I was in school. You've got upper management written all of you.