This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

New to Hibernate  RSS feed

 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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.
 
No holds barred. And no bars holed. Except this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!