Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Why not use sets and/or map but Hibernate?

    Hi to all, I'm new to Hibernate thus what I can do is to pose a newbie question

    My question is: why not use Java data structures instead of Hibernate?
    Hibernate guarantees persistence of data on disk, but if I don't have that constraint what are others reasons that get preferrable to use Hibernate instead of maps or sets?

    My question is very stupid, but I want to understand what are the real pro of using Hibernate as persistence manager.

    Articles or tutorial that answer to my question are welcome

    Thanks to all!

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,354
    Rep Power
    6

    Default Re: Why not use sets and/or map but Hibernate?

    uh, Hibernate is for persistence in a DATABASE. That might also be a database that lives completely in memory.

    You don't need articles or tutorials, you need to go and read the documentation.

    Hibernate ORM - Hibernate ORM

    Before that you might need to learn about database theory and JDBC. Hibernate is not for the novices, its quite advanced technology.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: Why not use sets and/or map but Hibernate?

    Quote Originally Posted by gimbal2 View Post
    uh, Hibernate is for persistence in a DATABASE. That might also be a database that lives completely in memory.

    You don't need articles or tutorials, you need to go and read the documentation.

    Hibernate ORM - Hibernate ORM

    Before that you might need to learn about database theory and JDBC. Hibernate is not for the novices, its quite advanced technology.
    Thanks for the answer. I am consciousness about that, and I have been saying about persistence on disk.
    As a newbie point of view if I don't need to use DBMS features like ACID properties why I would wish to choose Hibernate instead of sets and maps approach?

    For example if I have the trivial situation as authors-books-genres relations in a DBMS (projected by avoiding loops in ER) and I want to replicate that situation using the three classes (author, book and genre) relating each others using HashSets and proper methods for updating these structures, what will be the drawbacks of use that approach instead of Hibernate technology? These drawbacks are bounded only in not using ACID properties or will also spread in future writing and mantaining code problems? There's others limitation mostly regarding to power of language?

  4. #4
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: Why not use sets and/or map but Hibernate?

    You always mention that you don't want to have an ACID capabilities, which mean that your data only exists during the lifetime of your application. When you close your application your Author, Book and Genre will be gone.

    Using Hibernate allows you to persist this data in the database. Comparing your solution to Hibernate seems to be not comparable. You might compare for instance JDBC technology with Hibernate. As when you create a Hibernate application it will need those data structure class (Author, Book and Genre) that will be mapped to a database table in the database.

    In JDBC you will have to write the SQL command manually to insert those data as an example, including the long boilerplace code. But using Hibernate you can tell hibernate to persist the Java object, instead of using a database sql command.

  5. #5
    Join Date
    Dec 2011
    Posts
    19
    Rep Power
    0

    Default Re: Why not use sets and/or map but Hibernate?

    Thanks a lot for the answer.
    Then I will try to implement some ideas using maps and sets, as I have been said before I don't need persistence and ACID properties.

    I will also involve on Hibernate for direct a comparation of solutions regarding to code maintainability and power.

Similar Threads

  1. Sets Question
    By Malv in forum New To Java
    Replies: 3
    Last Post: 07-22-2013, 08:15 PM
  2. Maps and Sets
    By darkblue24 in forum New To Java
    Replies: 19
    Last Post: 03-25-2010, 07:13 PM
  3. Maps and Sets
    By RedKMan in forum New To Java
    Replies: 3
    Last Post: 02-16-2010, 10:36 AM
  4. Replies: 2
    Last Post: 06-30-2007, 04:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •