-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 
Author Message
 Post subject: Lookup table strategy
PostPosted: Sun Dec 26, 2004 7:55 pm 
Newbie

Joined: Sun Dec 26, 2004 7:47 pm
Posts: 4
Hi everyone. I seem to have a hard time finding any references on how to handle lookup tables in Hibernate. Does anyone have a practical example on how to do this? Some of the lookup data in my application is used for the UI. So I would like to pre-populate lookup lists on the start up of the application

Thanks,

Sergey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 5:37 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You should be more specific to get help.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Lookup table strategy
PostPosted: Mon Dec 27, 2004 8:56 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
ssunduko wrote:
I seem to have a hard time finding any references on how to handle lookup tables in Hibernate. Does anyone have a practical example on how to do this? Some of the lookup data in my application is used for the UI. So I would like to pre-populate lookup lists on the start up of the application


What do you mean by 'lookup table'? Do you mean a table of entities with names, where you would like to populate lists used for dropdown controls or selects?


Top
 Profile  
 
 Post subject: Re: Lookup table strategy
PostPosted: Mon Dec 27, 2004 1:16 pm 
Newbie

Joined: Sun Dec 26, 2004 7:47 pm
Posts: 4
jdavis wrote:
ssunduko wrote:
I seem to have a hard time finding any references on how to handle lookup tables in Hibernate. Does anyone have a practical example on how to do this? Some of the lookup data in my application is used for the UI. So I would like to pre-populate lookup lists on the start up of the application


What do you mean by 'lookup table'? Do you mean a table of entities with names, where you would like to populate lists used for dropdown controls or selects?


table
USER
-----------
ID (PK)
FIRST_NAME
LAST_NAME
......
STATE_LIST_ID (FK)

table
STATE_LIST
------------------------
ID (PK)
NAME


Sample Data

USER
-------------------------
John
Doe
...........
7


STATE_LIST
-----------------
7
CA

I am not sure what you mean by "selects". I have a list of standard lookup tables, (e.g, states, credit card types, etc) which are associated with User table and Credit_Card table, etc. I would like to use state and credit card type information in the dropdown, therefore I would like to pre-cache this data in advance. When credit card type or state is selected I would like to record it in the database, but I do not want to go back and remap CA to 7 in the User table

Thanks,

Sergey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 1:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
read up on second-level caching


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 2:11 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
I think that Sergey want simple many-to-one relationship
It is enough that declare many-to-one in USER for STATE (for example) and set
lazy to false.Hibernate will populate lookup automatic.

regards
Peco


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 2:16 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
snpesnpe wrote:
I think that Sergey want simple many-to-one relationship
It is enough that declare many-to-one in USER for STATE (for example) and set
lazy to false.Hibernate will populate lookup automatic.

regards
Peco


Right, it seems like something that can be done with a simple query or with relationship mappings, lazily loaded or not.


Top
 Profile  
 
 Post subject: Re: Lookup table strategy
PostPosted: Mon Dec 27, 2004 2:22 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
ssunduko wrote:
I am not sure what you mean by "selects".


I mean selects as in HTML select tags with option tags in them.

ssunduko wrote:
I have a list of standard lookup tables, (e.g, states, credit card types, etc) which are associated with User table and Credit_Card table, etc. I would like to use state and credit card type information in the dropdown, therefore I would like to pre-cache this data in advance. When credit card type or state is selected I would like to record it in the database, but I do not want to go back and remap CA to 7 in the User table


I don't know what you mean by 'remap', but you can definitely avoid re-reading things from the database by enabling Hibernate's cache.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 2:25 pm 
Newbie

Joined: Sun Dec 26, 2004 7:47 pm
Posts: 4
snpesnpe wrote:
I think that Sergey want simple many-to-one relationship
It is enough that declare many-to-one in USER for STATE (for example) and set
lazy to false.Hibernate will populate lookup automatic.

regards
Peco


Hi Peco, not quite. There are two problems here.
1. Select dropdown data from the lookup table
2. When dropdown value is selected on the webpage commit it to the database as part of User record.

Since, lookup table does not change I do not want to reload them every time. Also, I would like to avoid creating objects for lookup tables if possible. Collection of State Objects would be a waste, since all they would contain is a single string. I would like to be able to map User Object to USER and STATE_LIST tables at the same. I know it is not possilbe in Hibernate 2, but 3 allows one to many mapping between objects and tables.

Thanks,

Sergey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 2:46 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Sergey,
2 will hibernate do with many-to-one, but for task 1 you have to create any object (collection)
for every lookup table
Is lookup table from oracle vocabulary ?

regards


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 5:58 pm 
Newbie

Joined: Sun Dec 26, 2004 7:47 pm
Posts: 4
snpesnpe wrote:
Sergey,
2 will hibernate do with many-to-one, but for task 1 you have to create any object (collection)
for every lookup table
Is lookup table from oracle vocabulary ?

regards


Thanks for your response. I do not think that lookup pertains specificaly to Oracle. It is just another data modeling technique for externalizing common data like states, countries, etc.

Thanks,

Sergey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 7:29 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
I haven't told that is oracle specific.I think that you work with oracle, only - they use this termin
it is more relational, less object oriented
regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.