-
1. Re: Primary Key problem in XML file?
armint Feb 7, 2002 9:56 AM (in response to ericjee)The <primkey-field> element should go after the last <cmp-field>
-
2. Re: Primary Key problem in XML file?
ericjee Feb 7, 2002 11:15 AM (in response to ericjee)It was there before originally and it threw the exception, i moved it up for clarity. The placement is not the reason.
ie
<display-name>User</display-name>
<ejb-name>User</ejb-name>
UserHome
User
<ejb-class>UserBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
True
<cmp-version>2.x</cmp-version>
<abstract-schema-name>User</abstract-schema-name>
<cmp-field>
<field-name>PKUserId</field-name>
</cmp-field>
<cmp-field>
<field-name>UserName</field-name>
</cmp-field>
<cmp-field>
<field-name>Password</field-name>
</cmp-field>
<cmp-field>
<field-name>AccountStatus</field-name>
</cmp-field>
<cmp-field>
<field-name>ExpirationDate</field-name>
</cmp-field>
<cmp-field>
<field-name>LockDate</field-name>
</cmp-field>
<primkey-field>PKUserId</primkey-field>
.....
still throws the error.
Any other thoughts, please?
Thanks, eric -
3. Re: Primary Key problem in XML file?
armint Feb 7, 2002 11:40 AM (in response to ericjee)How does jboss know what is the datatype of pkuserid in the first place?
I bet it checks the bean implementation. In your case, it will look at:
public abstract Integer getPKUserId();
public abstract void setPKUserId(Integer value); -
4. Re: Primary Key problem in XML file?
ericjee Feb 7, 2002 12:00 PM (in response to ericjee)I thought the same, but in numerous examples on the internet you can supply a
abstract int getsomething()
and a
abstract void setsomething(int value)
and use the key value java.lang.Integer in the XML file. So I did the same, I thought they just matched up by the containter since Integer is a wrapper for an int object.
ie
public abstract class JudgeBean implements EntityBean {
public abstract int getJudgeId();
public abstract void setJudgeId(int judgeId);
has xml dd file...
<ejb-jar>
<display-name>judge_case</display-name>
<enterprise-beans>
<display-name>JudgeEJB</display-name>
<ejb-name>JudgeEJB</ejb-name>
examples.judge_case.JudgeHome
examples.judge_case.Judge
<ejb-class>examples.judge_case.JudgeBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
True
<cmp-version>2.x</cmp-version>
<abstract-schema-name>JudgeBean</abstract-schema-name>
<cmp-field><field-name>judgeName</field-name></cmp-field>
<cmp-field><field-name>judgeId</field-name></cmp-field>
<primkey-field>judgeId</primkey-field>
Any more help? This should work the way I'm doing it, and I do not want to change my return type to Integer, it just wouldn't make sense according to numerous online examples.
Eric -
5. Re: Primary Key problem in XML file?
ericjee Feb 8, 2002 5:36 AM (in response to ericjee)So basically what I'm trying to say in the last post is that it still doesnt work even though its supposed to. Somebody please help! I don't understand why it thinks that PKUserId, which is type int, and is delared as <primkey-field>, is not the same type as java.lang.Integer. What else could be possibly wrong!!!!!
-
6. Re: Primary Key problem in XML file?
greathavoc Feb 24, 2002 10:55 PM (in response to ericjee)I'm currently using JBoss 3 Alpha and I'm having the same problem. It seems that we can't use a Java primitive as the primary key in the bean implementation, for JBoss that is. I did not find the same problem with J2EE RI. Maybe it's a bug in JBoss? Anyone got any ideas?
-
7. Re: Primary Key problem in XML file?
dsundstrom Feb 27, 2002 1:10 AM (in response to ericjee)A primary key can not be a primative. It is in the EJB 2.0 spec section 9.8.
-
8. Re: Primary Key problem in XML file?
roysun Mar 25, 2002 11:54 AM (in response to ericjee)Comparing ejb spec 1.1 and 2.0, they are almost same. They do not clearly say that "primary key must not be a primitive type".
But 1.1 supports primitive type as a primary key for sure.
Roy -
9. Re: Primary Key problem in XML file?
dward2 Mar 26, 2002 1:00 PM (in response to ericjee)A better place in the ejb2.0 spec is section 10.5.2, at the bullet called "public PrimaryKeyClass ejbCreate(...);"
Though is shows that cmp fields can be primitive (looking at it's 0 default for integer primitive), it does say in the second to last paragraph of the bullet that (for CMP), "The implementation of the Bean Provider's ejbCreate(...) methods should be coded to return a null." Obviously, this means you can't define your return type as a primitive.