-
1. Re: CMP Update problem
dsnyckers Aug 5, 2002 4:38 AM (in response to dsnyckers)In addition, you can find my ejb-jar.xml settings.
What I don't get is the fact that when JBoss tries to remove the language from the article, it looksup all articles with that language attached to it (this is what i can read from the server logs). If you want to, I can always send you the server logs by mail (as the attach file mechanism doesn't work on the forum).
/// EJB-JAR.XML ////////////////////////////////////////
...
Models an article
<ejb-name>ArticleEJB</ejb-name>
<local-home>com.presscollection.ejb.entity.LocalArticleHome</local-home>
com.presscollection.ejb.entity.LocalArticle
<ejb-class>com.presscollection.ejb.entity.ArticleBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
False
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Article</abstract-schema-name>
<cmp-field><field-name>id</field-name></cmp-field>
<cmp-field><field-name>title</field-name></cmp-field>
<cmp-field><field-name>subject</field-name></cmp-field>
<cmp-field><field-name>freetext</field-name></cmp-field>
<cmp-field><field-name>header</field-name></cmp-field>
<cmp-field><field-name>body</field-name></cmp-field>
<cmp-field><field-name>caption</field-name></cmp-field>
<primkey-field>id</primkey-field>
findAll
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql/>
...
Models a language
<ejb-name>LanguageEJB</ejb-name>
<local-home>com.presscollection.ejb.entity.LocalLanguageHome</local-home>
com.presscollection.ejb.entity.LocalLanguage
<ejb-class>com.presscollection.ejb.entity.LanguageBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
False
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Language</abstract-schema-name>
<cmp-field><field-name>id</field-name></cmp-field>
<cmp-field><field-name>code</field-name></cmp-field>
<cmp-field><field-name>name</field-name></cmp-field>
<primkey-field>id</primkey-field>
findAll
<query-method>
<method-name>findAll</method-name>
<method-params/>
</query-method>
<ejb-ql/>
...
<ejb-relation>
<ejb-relation-name>Article-Language</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>article-has-language</ejb-relationship-role-name>
One
<relationship-role-source>
<ejb-name>ArticleEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>language</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>language-of-article</ejb-relationship-role-name>
One
<relationship-role-source>
<ejb-name>LanguageEJB</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
...
////////////////////////////////////////////////////////
The code I execute
/// CODE ///////////////////////////////////////////////
LocalLanguage language;
LocalLanguageHome languageHome =
( LocalLanguageHome ) EJBResourceFactory.getFactory().lookUpLocalHome( LocalLanguageHome.class );
LocalArticle article;
LocalArticleHome articleHome =
( LocalArticleHome ) EJBResourceFactory.getFactory().lookUpLocalHome( LocalArticleHome.class );
article = articleHome.findByPrimaryKey( new Integer( articleId ) );
if ( article != null )
{
System.out.println( "UPDATING LANGUAGE [" + languageId + "]" );
// update language
language = languageHome.findByPrimaryKey( new Integer( languageId ) );
System.out.println( "LANG = [" + language + "]" );
article.setLanguage( language );
System.out.println( "LANG SET TO NEW LANG" );
}
////////////////////////////////////////////////////////
I'm completely stuck with this one, so a little bit of help is more than welcome.
Thanks in advance,
Dave -
2. Re: CMP Update problem
dsundstrom Aug 6, 2002 2:30 PM (in response to dsnyckers)I don't see any problems with the posted code. Have you tried removing the findAll query declarations or the correct ejb-ql for findAll in the ejb-ql element (SELECT OBJEC(a) FROM Article a).
-
3. Re: CMP Update problem
dsnyckers Aug 19, 2002 4:28 AM (in response to dsnyckers)Unfortunally, that didn't do the trick :(
I tried to remove both the findAll queries for Article and language. But I'm not using these finder methods.
I start from my test client, from which I call my remote ArticleFacade session bean. This bean then calls the findByPrimaryKey for the article as well as the language.
I've attached my jboss.xml, ejb-jar.xml, jbosscmp-jdbc.xml and my server logs.
I find it very odd that when it tries to do the remove relation method, it looks up all articles with the language that I try to remove. You can see this behaviour in my server logs. I don't know if this is causing the troubles?
I really appreciate any help,
Dave -
4. Re: CMP Update problem
dsnyckers Aug 19, 2002 5:58 AM (in response to dsnyckers)small correction :
it doesn't lookup all articles with the language that it tries to remove, but all articles with the language that I'm trying to set to the given article.
f.e.
- article (ID=1) has languageID 1
- when I try to set language with ID 4 to my article, it looks up all articles with languageID 4
I have no clue why ... -
5. Re: CMP Update problem
dsnyckers Aug 19, 2002 6:09 AM (in response to dsnyckers)I figured out that when I try to set a language that is not yet assigned to another article, my update works just fine.
From the moment that the language is already assigned to another article, I get the error ...
I hope this can assist in finding the problem ... -
6. Re: CMP Update problem
dsnyckers Aug 19, 2002 6:17 AM (in response to dsnyckers)Problem fixed ...
nevermind ... -
7. Re: CMP Update problem
prabhackar Jan 31, 2003 12:07 AM (in response to dsnyckers)i am getting the same exception when trying to create a patient bean and then update a cmr field(location) in the ejbpostcreate method of patient bean(shown in the example below)
location---------> patient
1 many (unidirectional)
i am having only local,localHome interfaces for both the beans and location is represented only as cmr field in the patient bean
request to help on how to solve this problem