Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Java Users: Hibernate - A -must- see

FortKnox (169099) writes | more than 10 years ago

User Journal 10

Everything I've always wanted out of JDBC has been done with the open source project, hibernate. What is it? Simply an object relation mapper. Basically, you feed it an object (and the object has an xml that maps the object to a table and stuff[1]) and it will map it to a database and do all the jdbc to get the info and update/insert the data. Other nice things include one-to-many, many-to-many, and many-to-one mappings. You don't have to worry aboutEverything I've always wanted out of JDBC has been done with the open source project, hibernate. What is it? Simply an object relation mapper. Basically, you feed it an object (and the object has an xml that maps the object to a table and stuff[1]) and it will map it to a database and do all the jdbc to get the info and update/insert the data. Other nice things include one-to-many, many-to-many, and many-to-one mappings. You don't have to worry about foreign keys or anything (except in the xml mapping files) because it will automatically get your object instead of just the foreign key (even lazy loading is available).

It -really- makes JDBC simple in java. You just make normal java objects, and feed it into hibernate to do your persisting. It all happens in real time (using reflexion and other fancy things) so it isn't a code generator, but an api. I really suggest taking a look at the project. Really does some amazing things.

[1] - of course, if you are into the 'XDoclet' scene, you can have xdoclet write all the xml for you with its javadoc hibernate tags. And ant has hibernate tasks, including creating the tables and stuff...

cancel ×

10 comments

Sorry! There are no comments related to the filter you selected.

Be careful (1)

Xerithane (13482) | more than 10 years ago | (#7341128)

We implemented a system like this in Perl, and it ended up working great unless we were doing mass object searching/sorting. Then it started sucking, and I mean hard.

Do you know how it handles that aspect of things?

Re:Be careful (1)

FortKnox (169099) | more than 10 years ago | (#7341686)

Yeah, it has its own version of SQL (so it keeps the 'object' paradigm rolling) that does the finds and such. Very effective and quick.

Re:Be careful (1)

Xerithane (13482) | more than 10 years ago | (#7342394)

One solution we were thinking of is using BerkeleyDB to manage the object keying, and handle the serialization of objects from a more 'standalone' DB.

Do you know what version of SQL it's using?

EJB, JDO? (1)

dmorin (25609) | more than 10 years ago | (#7341437)

Where does this fit in relation to, say, container managed persistence in EJBs, or Java Data Objects (JDO) via something like Castor? If the answer is "it runs without needing a J2EE container", so does Castor.

Re:EJB, JDO? (1)

FortKnox (169099) | more than 10 years ago | (#7341710)

never used castor, but I know it uses session beans for transactions if you want (that's what we are doing), and I've heard of projects that use entity beans before. But I'm no expert so you'd have to look at the doc, or ask questions.

Reflection is pretty sweet (1)

sielwolf (246764) | more than 10 years ago | (#7341447)

Gotta love dropping in a new class and letting it rip. I currently have a project where I'm reflecting in an object (that must extend a certain class) and I want it to process a DOM document but I don't care how many methods it wants to run. So what did I do? Just look for all methods ending in Processing and running them all in alphabetical order. So I can write one that only has one method or a class that has 100. Any errors I handle with a plain set of exception handlers and *blamo* done.

It's great because one class only needs to do a little flat file writing via XSLT while another needs to talk to a DB and create some tables.

OQL (1)

sql*kitten (1359) | more than 10 years ago | (#7341784)

Have you seen OQL [exolab.org] ? Looks like a similar idea.

Faster (1)

Safety Cap (253500) | more than 10 years ago | (#7344329)

For a while, they had a contest that whoever could prove that JDBC was faster than Hibernate would win. I don't believe that anyone ever collected.

torque this, buddy! (1)

jdiggans (61449) | more than 10 years ago | (#7346689)

Sounds a lot like Torque [apache.org] to me ... there are a bunch of object-relational mappers floating around. I've used Torque in several projects and found the same glee in time saving you voice above.

Technology is cool.
-j

so much to learn .... (1)

rbolkey (74093) | more than 10 years ago | (#7348290)

... to think my first attempt to do this sort of thing in college was to serialize objects using xml and put them into a mysql database. Technology IS cool :).
Check for New Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>