• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Rich persistent fields in entity beans

 
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of using String, Long, etc Java standard types as CMP fields in EB, I have complex classes of domain types, such as the following:
USPhoneNumber extends PhoneNumberDomain extends TextDomain.

Is it possible to use these classes as EJB 2.0 CMP persistent fields types?

How should I implement serialization and the way CMP populates the fields from the database?
[ February 07, 2007: Message edited by: Chu Tan ]
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use ejbStore/ejbLoad methods to populate the Custom object.

1. Before updating the DB [ejbStore, swap values from Custom object to
entityBean attributes]

2. entity bean persisted in the DB.

3. After reading from DB, ejbLoad method swap from entity attributes to
Custom object.

refer p304. ejb2.1 spec.

-Akilan
 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand your suggestion of overriding onload to perform transformation, however this can be tedious if I've multiple domains to be used over 100 EJBs. Just subclasses of TextDomain alone, I'd have PhoneNumberDomain, AddressDomain, ZipDomain, etc.

These domain classes contains validation logic, formatting logic and wraps only a single basic java type, such as String.

Is the mapping from java object types to SQL data types implementation specific?
[ February 12, 2007: Message edited by: Chu Tan ]
 
akilan irudaya raja
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, Table to Bean mapping is not given in ejb-jar.xml
 
Friends help you move. Good friends help you move bodies. This tiny ad will help:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic