Re: [JBoss-user] Container Responsibility for CMR Foreign Keys
Unfortunately, you can't use this kind of key generation with insert-after-ejb-post-create. [ 784322 ] INSERT after ejbPostCreate http://sourceforge.net/tracker/?func=detail&aid=784322&group_id=22866&atid=381174 By the spec (and current implementation), the primary key should be set in ejbCreate and available in ejbPostCreate. Which is impossible in the case there was no INSERT after ejbCreate. The entity key generation commands that work with insert-after-ejb-post-create are pk-sql and key-generator. Hanson, Matthew wrote: Hi, Per your request, I have tested a bean with auto-increment primary key fields and without foreign-key mappings. I created a mini-project for Jboss 3.2.2 comprised of only a single bean class that should have Hypersonic auto-increment and create a primary key for the bean. The bean has no relationships at all and does have the auto-increment tag. Additionally, just for thoroughness, all of the tags in standardjboss.xml are set to true. The null primary key exception was thrown again. --- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] Container Responsibility for CMR Foreign Keys
* * @jboss.column-name name="first_name" */ public abstract String getFirstName(); /** * @ejb.interface-method view="local" * @ejb.persistent-field * * @jboss.column-name name="first_name" */ public abstract void setFirstName(String theFirstName); /** * @ejb.interface-method view="local" * @ejb.persistent-field * * @jboss.column-name name="ssn" */ public abstract Integer getSSN(); /** * @ejb.interface-method view="local" * @ejb.persistent-field * * @jboss.column-name name="ssn" */ public abstract void setSSN(Integer theSSN); /** * @ejb.interface-method view="local" */ public abstract accountHolderBeanData getData(); /** * @ejb.interface-method view="local" */ public abstract void setData(accountHolderBeanData theData); /** * @ejb.interface-method view="local" */ public abstract accountHolderBeanValue getaccountHolderBeanValue(); /** * @ejb.interface-method view="local" */ public abstract void setaccountHolderBeanValue(accountHolderBeanValue theAccountHolderValue); /** * * @ejb.create-method */ public java.lang.Object ejbCreate(accountHolderBeanValue theValue) throws CreateException { System.out.println("in ejbCreate for value object..."); /*setAccountRoleId(new Integer(1)); setEmailAddress(theValue.getEmailAddress()); setEmailTypeCd(theValue.getEmailTypeCd()); setAccountPassword(theValue.getAccountPassword());*/ this.setaccountHolderBeanValue(theValue); return null; } public void ejbPostCreate(accountHolderBeanValue theValue) throws CreateException { } /** * * @ejb.create-method */ public java.lang.Object ejbCreate(String theEmailAddress, String theEmailTypeCd, String theAccountPassword) throws CreateException { System.out.println("in ejbCreate for email address..."); setAccountRoleId(new Integer(1)); setEmailAddress(theEmailAddress); setEmailTypeCd(theEmailTypeCd); setAccountPassword(theAccountPassword); return null; } public void ejbPostCreate(String theEmailAddress, String theEmailTypeCd, String theAccountPassword) throws CreateException { this.setAccountId(((accountHolderBeanPK) entityCtx.getPrimaryKey()).getAccountId()); } } Here is the jbosscmp-jdbc.xml (with auto-increment tag): http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd";> java:/DefaultDS Hypersonic SQL accountHolderBean account accountId account_id accountRoleId account_role_id emailAddress email_address emailTypeCd email_type_cd accountPassword account_password firstName first_name SSN ssn Thanks for all of the help so far! Regards, Matt Hanson -Original Message- From: Alexey Loubyansky [mailto:[EMAIL PROTECTED] Sent: Thursday, December 04, 2003 3:31 PM To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] Container Responsibility for CMR Foreign Keys Key generation commands in 3.2.1 are different from those in 3.2.2. In 3.2.2 you should have for generated fields. Could check whether key generation work for you w/o mapping foreign key fields to the primary key fields? Hanson, Matthew wrote: > Hi > > Just another FYI on the null primary key for auto-increment primary key > problem in jboss-3.2.2. Basically, the auto-increment keys don't seem to > generate, and I get a null primary key error on creation. The suggestion > was to add to jbosscmp-jdbc.xml for the key fields. I did > that, and the failure still occurs. Just to be sure, I simply deployed the > jar to 3.2.1. With 3.2.1, the deployment failed with the following error: > > 2003-12-04 13:50:16,738 ERROR >
Re: [JBoss-user] Container Responsibility for CMR Foreign Keys
Key generation commands in 3.2.1 are different from those in 3.2.2. In 3.2.2 you should have for generated fields. Could check whether key generation work for you w/o mapping foreign key fields to the primary key fields? Hanson, Matthew wrote: Hi Just another FYI on the null primary key for auto-increment primary key problem in jboss-3.2.2. Basically, the auto-increment keys don't seem to generate, and I get a null primary key error on creation. The suggestion was to add to jbosscmp-jdbc.xml for the key fields. I did that, and the failure still occurs. Just to be sure, I simply deployed the jar to 3.2.1. With 3.2.1, the deployment failed with the following error: 2003-12-04 13:50:16,738 ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()' Cause: Incomplete Deployment listing: Packages waiting for a deployer: Incompletely deployed packages: MBeans waiting for classes: MBeans waiting for other MBeans: [ObjectName: jboss.j2ee:jndiName=homebrew/ejb/entity/accountHolderBean,service=EJB state: FAILED I Depend On: Depends On Me: java.lang.IllegalStateException: auto-increment template not found] So, in 3.2.1, I removed the tag from the beans, and the app deploys and the bean works (i.e., auto-increment keys are generated properly). Can you tell me why the auto-increment tag was suggested for 3.2.2? Are there additional tags that must be included? Please help!!! Regards, Matt Hanson --- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] Container Responsibility for CMR Foreign Keys
Hi Just another FYI on the null primary key for auto-increment primary key problem in jboss-3.2.2. Basically, the auto-increment keys don't seem to generate, and I get a null primary key error on creation. The suggestion was to add to jbosscmp-jdbc.xml for the key fields. I did that, and the failure still occurs. Just to be sure, I simply deployed the jar to 3.2.1. With 3.2.1, the deployment failed with the following error: 2003-12-04 13:50:16,738 ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()' Cause: Incomplete Deployment listing: Packages waiting for a deployer: Incompletely deployed packages: MBeans waiting for classes: MBeans waiting for other MBeans: [ObjectName: jboss.j2ee:jndiName=homebrew/ejb/entity/accountHolderBean,service=EJB state: FAILED I Depend On: Depends On Me: java.lang.IllegalStateException: auto-increment template not found] So, in 3.2.1, I removed the tag from the beans, and the app deploys and the bean works (i.e., auto-increment keys are generated properly). Can you tell me why the auto-increment tag was suggested for 3.2.2? Are there additional tags that must be included? Please help!!! Regards, Matt Hanson -Original Message- From: Hanson, Matthew [mailto:[EMAIL PROTECTED] Sent: Thursday, December 04, 2003 7:03 AM To: '[EMAIL PROTECTED]' Subject: RE: [JBoss-user] Container Responsibility for CMR Foreign Keys Hi! Yes, the pk columns have been created with the identity attribute. FYI - the key generation did work properly when the app was deployed to 3.2.1. It's just that w/3.2.1, I had to do some inefficient fk setting that I hope to avoid with the 3.2.2 config option. Regards! Matt Hanson -Original Message- From: Alexey Loubyansky [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 3:43 PM To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] Container Responsibility for CMR Foreign Keys Is the column in the database was created with IDENTITY attribute? Hanson, Matthew wrote: > Hi-- > > Well, I added the auto-increment tag to jbosscmp-jdbc.xml, and the null > primary key exception is still thrown: > --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] Container Responsibility for CMR Foreign Keys
Hi! Yes, the pk columns have been created with the identity attribute. FYI - the key generation did work properly when the app was deployed to 3.2.1. It's just that w/3.2.1, I had to do some inefficient fk setting that I hope to avoid with the 3.2.2 config option. Regards! Matt Hanson -Original Message- From: Alexey Loubyansky [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 3:43 PM To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] Container Responsibility for CMR Foreign Keys Is the column in the database was created with IDENTITY attribute? Hanson, Matthew wrote: > Hi-- > > Well, I added the auto-increment tag to jbosscmp-jdbc.xml, and the null > primary key exception is still thrown: > --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
Re: [JBoss-user] Container Responsibility for CMR Foreign Keys
Is the column in the database was created with IDENTITY attribute? Hanson, Matthew wrote: Hi-- Well, I added the auto-increment tag to jbosscmp-jdbc.xml, and the null primary key exception is still thrown: --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] Container Responsibility for CMR Foreign Keys
count_id accountRoleId account_role_id emailAddress email_address emailTypeCd email_type_cd accountPassword account_password firstName first_name SSN ssn Account-Recipe Recipe-Belongs-To-Account Account-Has-Recipes accountId account_id Recipe-Hops Recipe-Has-Hops recipeId recipe_id Hops-Belongs-To-Recipe Account-Address Account-Has-Addresses accountId account_id Address-Belongs-To-Account Any other ideas? Regards, Matt Hanson -Original Message- From: Alexey Loubyansky [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 10:52 AM To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] Container Responsibility for CMR Foreign Keys The auto incremented/generated field should have in jbosscmp-jdbc.xml --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
Re: [JBoss-user] Container Responsibility for CMR Foreign Keys
The auto incremented/generated field should have in jbosscmp-jdbc.xml --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] Container Responsibility for CMR Foreign Keys
ressBean AccountRecipeBean * Required RecipeHopsBean * Required accountAddressBean * Required accountHolderBean * Required Here is jbosscmp-jdbc.xml: http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd";> java:/DefaultDS Hypersonic SQL AccountRecipeBean recipe recipeId recipe_id accountId account_id recipeName recipe_name RecipeHopsBean java:/DefaultDS Hypersonic SQL recipe_hops recipeHopId recipe_hop_id recipeId recipe_id hopsRefId ref_recipe_hops_id hopForm hop_form accountAddressBean account_address accountId account_id addressType address_type streetNumber str_num streetName str_name streetSuffix str_suffix city city state state zipCode zip zip4 zip4 primaryAddress primary_address billingAddress billing_address accountHolderBean account accountId account_id accountRoleId account_role_id emailAddress email_address emailTypeCd email_type_cd accountPassword account_password firstName first_name SSN ssn Account-Recipe Recipe-Belongs-To-Account Account-Has-Recipes accountId account_id Recipe-Hops Recipe-Has-Hops recipeId recipe_id Hops-Belongs-To-Recipe Account-Address Account-Has-Addresses accountId account_id Address-Belongs-To-Account Any advice? Thanks!!! Regards, Matt Hanson -Original Message- From: Alexey Loubyansky [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 9:51 AM To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] Container Responsibility for CMR Foreign Keys How the beans is configured in ejb-jar.xml and jbosscmp-jdbc.xml? Hanson, Matthew wrote: > Hi, > > I have modified the reentrancy tags for my beans to false, deployed the > beans to binary download of Jboss 3.2.2 with insert-after-ejb-post-create, > and now I catch the following exception in ejbCreate of the n-side bean: > > 2003-12-03 09:15:53,858 ERROR [org.jboss.ejb.plugins.LogInterceptor] > TransactionRolledbackLocalException in method: public abstract void > homebrew.ejb.interfaces.accountHolderBeanLocal.setaccountHolderBeanValue(hom > ebrew.ejb.interfaces.accountHolderBeanValue), causedBy: > javax.ejb.CreateException: Primary key for created instance is null. > at > org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManage > r.java:520) > at > org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManag > er.java:208) > at > org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntit > y(CachedConnectionInterceptor.java:269) > at > org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:580) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 > ) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl > .java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > >
Re: [JBoss-user] Container Responsibility for CMR Foreign Keys
How the beans is configured in ejb-jar.xml and jbosscmp-jdbc.xml? Hanson, Matthew wrote: Hi, I have modified the reentrancy tags for my beans to false, deployed the beans to binary download of Jboss 3.2.2 with insert-after-ejb-post-create, and now I catch the following exception in ejbCreate of the n-side bean: 2003-12-03 09:15:53,858 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract void homebrew.ejb.interfaces.accountHolderBeanLocal.setaccountHolderBeanValue(hom ebrew.ejb.interfaces.accountHolderBeanValue), causedBy: javax.ejb.CreateException: Primary key for created instance is null. at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManage r.java:520) at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManag er.java:208) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntit y(CachedConnectionInterceptor.java:269) at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:580) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) Is the for the bean is being ignored in Jboss 3.2.2? Please advise! Thanks! Regards, Matt Hanson -Original Message- From: Alexey Loubyansky [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 3:27 PM To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] Container Responsibility for CMR Foreign Keys By the spec, you may not establish relationships in ejbCreate but may in ejbPostCreate. By default, INSERT is done after ejbCreate but before ejbPostCreate. You can use insert-after-ejb-post-create to delay INSERT until after ejbPostCreate but this feature is available, AFAIR, since 3.2.2. Hanson, Matthew wrote: Hi, I am using xdoclet 1.2b2 to generate deployment descriptors and classes, including value objects, for two beans that I hope to write with support for CMR. We also use Jboss 3.2.1 as my app server and hypersonic and/or mysql as the db. Basically, I just want to write a relatively "ejb-standard" foreign keyed insert for 1:n-related beans that are both being creating together. The bean class generated by xdoclet maintains vectors of added, removed, and updated value objects of the type that is the n-side of the 1:n relationship that I hope to support. It also generates a set...BeanValue() method to process the 1-side bean value object. This set...BeanValue() methods iterates across the n-side value objects and tries to create the n-siders via the create followed by Collection.add methods. The keys on the 1-side, however, are not included in the value object, and the create fails the non-null foreign key constraint. Before posting to xdoclet, I stepped back and started to think that the ejb container (Jboss) should probably creating and assigning foreign keys to the n-side with the local interface set methods. The ejb spec, however, does not seem to support this thought, and I do see posts on the jboss site that say the setting of foreign keys of the n-side is generally done in the ejbPostCreate method of the 1-side. Well, I tried that, and I can output the n-side value objects in the 1-side ejbPostCreate and see the updated key field, but the insert on the n-side still fails!?!?!?!?. Now, I also see in the posts that Jboss 3.2.2 may offer a new tag in standardjboss.xml that prompts the app server to wait until after ejbPostCreate to try to write the n-side of the datasource. Before I spend another day on this, I am wondering if someone can just tell me: (1) Are these keyed inserts on related beans even possible? (2) What is the recommended way to do them? (Code, new jboss version, other?) Wow - I hope that I am making some sense, because it seems like a very common thing to do... Any help would be great! Regards, Matt Hanson --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge
RE: [JBoss-user] Container Responsibility for CMR Foreign Keys
Hi, I have modified the reentrancy tags for my beans to false, deployed the beans to binary download of Jboss 3.2.2 with insert-after-ejb-post-create, and now I catch the following exception in ejbCreate of the n-side bean: 2003-12-03 09:15:53,858 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract void homebrew.ejb.interfaces.accountHolderBeanLocal.setaccountHolderBeanValue(hom ebrew.ejb.interfaces.accountHolderBeanValue), causedBy: javax.ejb.CreateException: Primary key for created instance is null. at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManage r.java:520) at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManag er.java:208) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntit y(CachedConnectionInterceptor.java:269) at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:580) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) Is the for the bean is being ignored in Jboss 3.2.2? Please advise! Thanks! Regards, Matt Hanson -Original Message- From: Alexey Loubyansky [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 3:27 PM To: [EMAIL PROTECTED] Subject: Re: [JBoss-user] Container Responsibility for CMR Foreign Keys By the spec, you may not establish relationships in ejbCreate but may in ejbPostCreate. By default, INSERT is done after ejbCreate but before ejbPostCreate. You can use insert-after-ejb-post-create to delay INSERT until after ejbPostCreate but this feature is available, AFAIR, since 3.2.2. Hanson, Matthew wrote: > Hi, > > I am using xdoclet 1.2b2 to generate deployment descriptors and classes, > including value objects, for two beans that I hope to write with support for > CMR. We also use Jboss 3.2.1 as my app server and hypersonic and/or mysql > as the db. > > Basically, I just want to write a relatively "ejb-standard" foreign keyed > insert for 1:n-related beans that are both being creating together. > > The bean class generated by xdoclet maintains vectors of added, removed, and > updated value objects of the type that is the n-side of the 1:n relationship > that I hope to support. It also generates a set...BeanValue() method to > process the 1-side bean value object. This set...BeanValue() methods > iterates across the n-side value objects and tries to create the n-siders > via the create followed by Collection.add methods. The keys on the 1-side, > however, are not included in the value object, and the create fails the > non-null foreign key constraint. > > Before posting to xdoclet, I stepped back and started to think that the ejb > container (Jboss) should probably creating and assigning foreign keys to the > n-side with the local interface set methods. The ejb spec, however, does > not seem to support this thought, and I do see posts on the jboss site that > say the setting of foreign keys of the n-side is generally done in the > ejbPostCreate method of the 1-side. Well, I tried that, and I can output > the n-side value objects in the 1-side ejbPostCreate and see the updated key > field, but the insert on the n-side still fails!?!?!?!?. > > Now, I also see in the posts that Jboss 3.2.2 may offer a new tag > in standardjboss.xml that prompts the app > server to wait until after ejbPostCreate to try to write the n-side of the > datasource. > > Before I spend another day on this, I am wondering if someone can just tell > me: > (1) Are these keyed inserts on related beans even possible? > (2) What is the recommended way to do them? (Code, new jboss version, > other?) > > Wow - I hope that I am making some sense, because it seems like a very > common thing to do... > > Any help would be great! > > Regards, > Matt Hanson > > > --- > This SF.net email is sponsored by OSDN's Audience Survey. > Help shape OSDN's sites and tell us what you think. Take this > five minute survey and you could win a $250 Gift Certificate. > http://www.wrgsurveys.com/2003/osdntech03.php?site=8 > ___ > JBoss-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-user > > --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could
Re: [JBoss-user] Container Responsibility for CMR Foreign Keys
By the spec, you may not establish relationships in ejbCreate but may in ejbPostCreate. By default, INSERT is done after ejbCreate but before ejbPostCreate. You can use insert-after-ejb-post-create to delay INSERT until after ejbPostCreate but this feature is available, AFAIR, since 3.2.2. Hanson, Matthew wrote: Hi, I am using xdoclet 1.2b2 to generate deployment descriptors and classes, including value objects, for two beans that I hope to write with support for CMR. We also use Jboss 3.2.1 as my app server and hypersonic and/or mysql as the db. Basically, I just want to write a relatively "ejb-standard" foreign keyed insert for 1:n-related beans that are both being creating together. The bean class generated by xdoclet maintains vectors of added, removed, and updated value objects of the type that is the n-side of the 1:n relationship that I hope to support. It also generates a set...BeanValue() method to process the 1-side bean value object. This set...BeanValue() methods iterates across the n-side value objects and tries to create the n-siders via the create followed by Collection.add methods. The keys on the 1-side, however, are not included in the value object, and the create fails the non-null foreign key constraint. Before posting to xdoclet, I stepped back and started to think that the ejb container (Jboss) should probably creating and assigning foreign keys to the n-side with the local interface set methods. The ejb spec, however, does not seem to support this thought, and I do see posts on the jboss site that say the setting of foreign keys of the n-side is generally done in the ejbPostCreate method of the 1-side. Well, I tried that, and I can output the n-side value objects in the 1-side ejbPostCreate and see the updated key field, but the insert on the n-side still fails!?!?!?!?. Now, I also see in the posts that Jboss 3.2.2 may offer a new tag in standardjboss.xml that prompts the app server to wait until after ejbPostCreate to try to write the n-side of the datasource. Before I spend another day on this, I am wondering if someone can just tell me: (1) Are these keyed inserts on related beans even possible? (2) What is the recommended way to do them? (Code, new jboss version, other?) Wow - I hope that I am making some sense, because it seems like a very common thing to do... Any help would be great! Regards, Matt Hanson --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user --- This SF.net email is sponsored by OSDN's Audience Survey. Help shape OSDN's sites and tell us what you think. Take this five minute survey and you could win a $250 Gift Certificate. http://www.wrgsurveys.com/2003/osdntech03.php?site=8 ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user