• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

New to Hibernate

 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just reading up hibernate right now, it seems to be pretty cool. I'm updating an application which interact with database. I can't chaneg the database design because other external tools use and update it as well.
The databae contains over 8000 tables, each table definition is the same, with the except of data itself. Each table has about 2000 - 50000 records.
Hibernate was suggested and we are doing reseach right now. I like the idea the that no more JDBC and sql, but from my research, it seems that we have to maintain the mapping files, which is abit too much considering 8000 tables.
If I read the document wrong, please correct me. The last thing I want to do is to getting all the user interface and logic done, then stuck with Hibernate part and realize it's a maintenance nightmare.
Any help is appreciated.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If there really are 8000 (!) tables and they're basically identical except for name and data, I would probably be looking at using a single, parameterized DAO for those tables.
I.e. something like
MyGenericDAO dao = new MyGenericDAO("table7999");
Record record = dao.getRecord(123);
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also new to hibernate, I have read that if you use xdoclet (hibernatedoclet), it can generate the mapping for you, so in theory,
it can save you a lot of time.
http://xdoclet.sourceforge.net
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, there are 8000 tables, and I can't do anything about it because too many vendors update the tables. I really would hate to write SQL for my application, I'm looking at any other options that can help me to simply the process.
I'm not sure what DAO (Data Access Object?) is.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adrian Yan:
I'm not sure what DAO (Data Access Object?) is.

Exactly.
If the tables really are identical, it should be possible to write one DAO and parameterize the table name. The SQL would then be constructed dynamically for each new instance of the DAO class with "SELECT * FROM table_" + tableName + " WHERE id = ?", for example
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool, I see it now. That pattern is what I had in mind without knowing it's a pattern . I guess there is no way to avoid SQL now . That's fine, it should work just fine. Thanks for the help guys.
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adrian Yan:
Cool, I see it now. That pattern is what I had in mind without knowing it's a pattern . I guess there is no way to avoid SQL now . That's fine, it should work just fine. Thanks for the help guys.


Of course there is. However, your requirements don't call for something as sophisticated as Hibernate. When given two choices and all things being equals always choose the simplest option. In this case, the simplest thing appears to be writing a bit of JDBC code.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic