-
1. Re: CMP Foreign Key problem!
jamarkha Sep 10, 2003 9:13 AM (in response to crazypalm)Show us your client code and the ejbCreate/ejbPostCreate methods for each EJB.
-
2. Re: CMP Foreign Key problem!
crazypalm Sep 10, 2003 9:14 AM (in response to crazypalm)BTW, the field MessageContent.TransactionId is null in every trial. :(
-
3. Re: CMP Foreign Key problem!
crazypalm Sep 10, 2003 9:21 AM (in response to crazypalm)Nothing special actually in each create();
in TransactionBean:
/**
* @ejb.create-method
*/
public String ejbCreate(String TransactionId, long accountId ) throws CreateException {
long currentTime = System.currentTimeMillis();
Timestamp stamp = new Timestamp(currentTime);
try {
this.setId(s_keygen.generateKey().toString());
this.setTransactionId(vaspTransactionId);
this.setAccountId(accountId);
this.setTimeStamp(stamp);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
in MessageContentBean
/**
* @ejb.create-method
*/
public String ejbCreate(MessageContentData data) throws CreateException
{
try
{
setId(s_keygen.generateKey().toString());
data.setId(getId());
setData(data);
s_log.info("Generated Key:" + getId());
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
the Client code just generate MessageContentData and call create. (because Messagecontent.TransactionID is foreignkey, there are no setTransactionId() or getTransactionId(). How can I store the transactionId then?) :( -
4. Re: CMP Foreign Key problem!
jamarkha Sep 10, 2003 11:49 AM (in response to crazypalm)If you want the relationship to be set on ejbCreate(), you need to actually set relationships in a CMP Bean's ejbPostCreate().
Since the signature for that is the same as ejbCreate, I can see that you do not have as a parameter any reference to a local object for which you want a relationship.
Example:
http://xpetstore.sourceforge.net/java2html/xpetstore-ejb/xpetstore/domain/customer/ejb/CustomerEJB.java.html -
5. Re: CMP Foreign Key problem!
crazypalm Sep 11, 2003 7:58 AM (in response to crazypalm)Hi,
Thanks a lot for your reply.
Actually, i read through xpetstore codes again and agian. Then i try modify the create() to ejbCreate(MessageContentLocal mcl, String TransactionId, long accountId ) and ejbCreate(MessageContentLocal mcl, TransactionData tdata), and ejbPostCreate() as well.
Then how can I write the clientcode since i dn't know how to get the MessageContentLocal.
Also, i found these lines in xpetstore Customer:
* @ejb.value-object
* compose="xpetstore.domain.signon.model.AccountValue"
* compose-name="AccountValue"
* members="xpetstore.domain.signon.interfaces.Account"
* members-name="AccountValue"
* relation="external"
what that means? I added these tags in my CMR field, i got compilation error says getMessageContent() not found something.
I absolutely have no idea waht to do now.