• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

CMP: cannot define my own business function?

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This sounds a silly question. I hope you can stay with me for a moment.
I use WebLogic 6.1, I keep getting error messages whenever I want to write non-cmp business method on CMP EntityBean.
public interface Customer extends EJBObject {
...
public ProfileVO _getProfile() throws RemoteException;
public void _setProfile(ProfileVO profile) throws RemoteException;
...
}
Basically, ProfileVO is a value object contains name, address, etc. And ProfileVO object is going to be serialized into database as single String value profile (CMP field).
The bean code:
...
public abstract class CustomerEJB implements EntityBean {
...
// this is a CMP field
public String profile;
// this is not a CMP field
public ProfileVO profileVo;
public ProfileVO _getProfile() {
return profileVo;
}
public void _setProfile(ProfileVO p) {
profileVo = p;
}
public void ejbLoad() {
// ProfileVO can accept String as argument,
// and parse it to get the customer name,
// address, etc.
profileVo = new ProfileVO(profile);
}
public void ejbStore() {
// this will convert ProfileVO to String
// so it can be saved into database
profile = profileVO.constructString();
}
...
}
The error told something about "field definition mismatch" or similar.. My code can be compiled *only* when I remove _setProfile and _getProfile in Customer remote interface. Why?
PS: It works fine when I use BMP ...
 
Alexander Yanuar Koentjara
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now it works .. hmm .. not my code, but this is WL's fault not to conform EJB spec.
If I replace _setProfile with setProfileVO and _getProfile with getProfileVO, and declare dummy variable:
ProfileVO profileVO;
Then, it works. This is weird though since profileVO is not a cmp field, why should I bother to declare it according to get/set EJB2.0 contract? The funny thing, if the return value is a subclass of Collection/Set, it never complain.
 
This one time, at bandcamp, I had relations with a tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic