Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Hibernate Question

Options
  • 11-01-2014 4:48pm
    #1
    Registered Users Posts: 8,324 ✭✭✭


    I'm using Hibernate for my FYP and I've not really looked into it as such, but I can a query based on the design of the project.

    I have a Tournament class. Within this tournament, one possible design choice is having a List of eligible participants (such as a Male Advanced Tennis Tournament which would only allow Male members with an Advanced Rank). The list would then be populated with all members who meet this criteria. If someone were to attempt to join the tournament, it would be checked against this list.

    As I said, I've not looking too much into it yet (and will be next week) but I'm currently using jdbc with Spring. From my understanding, I can't store a list in one field, and I can't create a set number of fields as there could be any possible number of eligible members up to the total number of members.

    Can Hibernate store the List object in one field? I'm guessing that may be the point of it, but no harm in asking before I get into it during the week!


Comments

  • Registered Users Posts: 11,979 ✭✭✭✭Giblet


    You need a many to many relationship, so you would have a table that maps a tournament to an eligible participant.

    The table would look something like this.
    TournamentId  |  ParticipantId
    1                  1
    1                  2
    1                  3
    

    Hibernate will automatically know to fill the list with the correct entities.


  • Moderators, Technology & Internet Moderators Posts: 1,334 Mod ✭✭✭✭croo


    Can Hibernate store the List object in one field?
    Keep in mind that hibernate is not a database in itself but rather Object Relational Mapoing [ORM] library - so there is still a need for a relational database behind it.


  • Registered Users Posts: 8,324 ✭✭✭chrislad


    croo wrote: »
    Keep in mind that hibernate is not a database in itself but rather Object Relational Mapoing [ORM] library - so there is still a need for a relational database behind it.

    I know, cheers. Just moving from standard jdbc with named parameters to hibernate.

    Will keep the many to many relationship in mind. Thanks.


  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    chrislad wrote: »
    I know, cheers. Just moving from standard jdbc with named parameters to hibernate.

    Will keep the many to many relationship in mind. Thanks.

    Have a look at appfuse for creating the project using maven, the maven config will show you how hibernate can automatically create the database for you (and populate it with test data if you wish).

    Oh and use annotation based configuration its far simplier than wiring the whole thing up in XML.


  • Registered Users Posts: 8,324 ✭✭✭chrislad


    I've already created the project using Maven, though it's just a standard archetype. I'm currently using MySQL, with the MySQL Workbench for the database. Will this not be sufficient for Hibernate?


  • Advertisement
  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    chrislad wrote: »
    I've already created the project using Maven, though it's just a standard archetype. I'm currently using MySQL, with the MySQL Workbench for the database. Will this not be sufficient for Hibernate?

    That will work fine, its just that while you are developing you will probably want to recreate and repopulate the database with test data. DbUnit with Maven makes this really fast http://dbunit.sourceforge.net/


Advertisement