This is a bad idea. You are effectively creating two caches of the same
data, but there is no code to keep them in sync. Although this may work
today, you could get weird non-reproducible errors down the road.

Dan pointed out that engine can delay insert until after postCreate or until
the end of the transaction, but that change will not hapen any time soon.

-dain

> -----Original Message-----
> From: Dobridge, Thomas A [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 31, 2001 4:40 PM
> To: '[EMAIL PROTECTED]'
> Subject: [JBoss-dev] Non-NULL foreign key CMR
> 
> 
> There was a  brief discussion on this recently but I didn't 
> quite get the
> jist of it.
> 
> Just wan't to clarify that with latest jboss3.0.0alpha CMP 
> code, it appears
> for now that the INSERT statement generated for  
> ejbCreate(..)  depends
> solely on the list of defined cmp-fields.     I have several 
> cases where CMR
> fields are in Many-1 relations that rely on foreign keys with non-null
> contraints.   So what I've done to get this to work is 
> created seemingly
> redundant CMP and CMR fields with different names but mapped 
> to the same
> column.
> 
> Specifically, I have Organization-OrganizationType in a Many-one CMR
> relationship.  Here are some fragments: I hope this get's the 
> point across.
> 
> OrganizationBean.java has this
> 
>               // cmp field  mapped to 
> ORGANIZATION.ORGANIZATION_TYPE as
> field name organizationTypeKey
>               public abstract String getOrganizationTypeKey();   
>               public abstract void setOrganizationTypeKey(String
> organizationTypeKey);                     
> 
>               // CMR field mapped to same column with field name
> organizationType
>               public abstract OrganizationType getOrganizationType(); 
>               public abstract void 
> setOrganizationType(OrganizationType
> organizationType);
> 
> 
> Then  I have this:
> 
>       public BigDecimal ejbCreate(String name,
>                                     OrganizationType organizationType)
>                       throws CreateException, RemoteException {
> 
>               setOrganizationKey(new
> BigDecimal(System.currentTimeMillis()));  // goofy test
>               
>               // should this be called?  weblogic message boards on
> dejanewssuggest otherwise but I am not sure.
>       
> setOrganizationTypeKey(organizationType.getOrganizationType()); 
>               setName(name);
>               return null;
>       }
> 
>       public void ejbPostCreate(String name,
>                                OrganizationType organizationType)
>                       throws CreateException, RemoteException {
> 
>                               
> setOrganizationType(organizationType);  //
> cmr fields deferred to postCreate???
> 
>       }
> 
> 
> This tooks  several try guessing at various approaches to get 
> it working.
> Am I doing this right?
> 
> regards,
> 
> Tom D.
> 
> 
> 
>   
> 
> 
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-development
> 

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to