Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Rich persistent fields in entity beans  RSS feed

 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • 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 ]
 
akilan irudaya raja
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
yes, Table to Bean mapping is not given in ejb-jar.xml
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!