• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Computed value in the entity bean

 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have an entity bean that has for e.g. three fields.
PersonBean
1. Name
2. DOB
3. Age
Now, I have CMP for that bean. The Age is a computed value from the field DOB. So, how do I make the container insert that in the bean on insert/update queries...etc.
This is a specific example but one can have any column in the DB Table to be "derived" (to use database terminology) from other colum/coumns in some defined way.
How to handle this situation using CMP? If we just take the above AGe example we can do some EJB-QL magic (I guess) to compute the Age but what would be a general way of handling this type of scenario?
Regards
Maulin
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, probably what we have to do is, compute the derived column and via the session bean (using session facade) call entitybean.setXXX() field just like settting other persistent fields for that computed column we have in the database and so when container calls ejbStore() it automatically stores the computed value in the corresponding column BUT my situation is little different because I have,
- ITEM_COLLECTION entity bean . Dbtable: (ITEM_COLLECTION_ID,ITEMS_INFO1,..., PK(ITEM_COLLECTION_ID))
- ITEM entity bean. Dbtable (ITEM_COLLECTION_ID, ITEM_ID,ITEM_INFO1,..., PK(ITEM_COLLECTION_ID,ITEM_ID))
Now, I want to generate a comma separated list of ITEM_INFO1 for ITEMs in one collection and put it in ITEMS_INFO1 field in ITEM_COLLECTION column you know. So, whenever any ITEM changes I need to somehow have a callback to the corresponding ITEM_COLLECTION entity bean to update its ITEM_INFO1 by running some query again to refresh the entry...
You can consider this ITEM_INFO1 in ITEM as short description for the ITEM and ITEMS_INFO1 in ITEM_COLLECTION as comma separated values to be shown under ITEM_COLLECTION in the display you know...
Hope I am able to explain my situation.
Regards
Maulin
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody has got any ideas here?
I hope I was able to put down my problem properly.
Regards
Maulin
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Have u tried writing the same code in ejbPostCreate method?
Seetesh
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic