Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

OR mapping for java.util.Hashtables?

Thread view: 
Philipp Leitner - 12 Jul 2006 08:38 GMT
Hi all,

I was just recently wondering how you (or, for that matter, any
standard OR mapping library like Hibernate) would map a
java.util.Collection datastructure to a relational database? I guess
there has to be a well-known approach to that problem - I just can't
find it for the for the life of me :-)

Can anybody help me out on that? Precisely I need to map a
java.util.Hashtable to a HSQL database without using any specific OR
library.

thx in advance,
Philipp
Oliver Wong - 12 Jul 2006 22:19 GMT
> Hi all,
>
[quoted text clipped - 3 lines]
> there has to be a well-known approach to that problem - I just can't
> find it for the for the life of me :-)

   Different data structures would get mapped differently.

> Can anybody help me out on that? Precisely I need to map a
> java.util.Hashtable to a HSQL database without using any specific OR
> library.

   Store the keys somehow. Assume the keys have an ID.
   Store the values somehow. Assume the values have an ID.

   If you only need to store one Hashtable, you can create an SQL table to
represent that table with two columns. The first column is a reference to a
key id, and the second column is a reference to a value id. I.e. you're
storing a relationship between a key and a value.

   If you need to store multiple hashtables, add a third column which is
the ID of the hashtable to which the relationship belongs.

   - Oliver
Philipp Leitner - 13 Jul 2006 08:17 GMT
>     Store the keys somehow. Assume the keys have an ID.
>     Store the values somehow. Assume the values have an ID.
[quoted text clipped - 3 lines]
> key id, and the second column is a reference to a value id. I.e. you're
> storing a relationship between a key and a value.

arg ... I knew there had to be a simple way that I just didn't see. You
opened my eyes there - thanks a lot Oliver.

/philipp


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.