I can see how nulls could be a problem. But I don't think are my problem in
this case, for 2 reasons: The db is completely new and all data is added
through MyBean. In the ejbCreate method i have null/empty string checks on
these three fields (also eliminated from the example code below). The 2nd
reason that I don't think that nulls are the problem is that when I restart
the problem, goes away.

I can double check my db when I get into work tomorrow.

Any more ideas?

.peter

-----Original Message-----
From: Dain Sundstrom
To: [EMAIL PROTECTED]
Sent: 6/27/02 3:09 PM
Subject: Re: [JBoss-user] [JBossCMP2.0] Compound Primary Keys and CMR fiel
ds

Ok, I trust that you implemented it correctly.  If you don't then 
nothing works.

Usually the problem you are seeing is because you have existing data in 
you database that has null values, and you attempt to load the null 
values into a not-null fields.  All pk members must be not-null 
(required by the SQL spec) and all primitive values must be not-null 
(Java primitives can't be null).

-dain

Luttrell, Peter wrote:
> actually i have, I just omitted it in the example.
> it definiatly compiles.
> 
> .peter
> 
> -----Original Message-----
> From: Dain Sundstrom [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 27, 2002 2:32 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [JBoss-user] [JBossCMP2.0] Compound Primary Keys and CMR
> fields
> 
> 
> You have not implemented equals in your pk class.  That code shouldn't

> even compile?
> 
> -dain
> 
> Luttrell, Peter wrote:
> 
>>I have an entity bean with a compound primary key, where one of the 
>>fields is a cmr field. The entity bean works perfectly after the first

>>deployment. I can set primary key, as well as do lookups and such. But

>>after I redeploy (or restart) I get the following error, whenever i 
>>attempt to findByPrimaryKey for a valid record:
>> 
>>13:45:34,612 ERROR [STDERR] javax.ejb.FinderException: Find failed: 
>>javax.ejb.EJBException: Internal
>> error getting results for field member key
>>Embedded Exception
>>Unable to load a ResultSet column into a variable of type '....MyKey'
>>13:45:34,675 ERROR [STDERR]     at 
>>org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(J
>>DBCAbstractQueryCommand.java:143)
>>13:45:34,690 ERROR [STDERR]     at 
>>org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntityCommand.execute(JDBC
>>FindEntityCommand.java:44)
>>...
>> 
>>My question is, should what I am doing work? If so then this is a bug 
>>(or some other problem). If not, the beanvalidation should detect this

>>senerio and not allow the beans deployment.
>> 
>>Here's some more details on what I am doing:
>> 
>>     <entity>
>>            <ejb-name>MyBean</ejb-name>
>>            <prim-key-class>....MyKey</prim-key-class>
>>            ...
>>            <cmp-field><field-name>key</field-name></cmp-field>
>>            <cmp-field><field-name>year</field-name></cmp-field>
>>            <cmp-field><field-name>month</field-name></cmp-field>
>>            <primkey-field>key</primkey-field>
>>           ...
>>     </entity>
>> 
>> 
>>        <ejb-relation>
>>            <ejb-relation-name>....</ejb-relation-name>
>>            <ejb-relationship-role>
>>
> <ejb-relationship-role-name>.....</ejb-relationship-role-name>
> 
>>                <multiplicity>One</multiplicity>
>>                <relationship-role-source>
>>                    <ejb-name>...some other bean....</ejb-name>
>>                </relationship-role-source>
>>                <cmr-field>
>>                    <cmr-field-name>allMyBeans</cmr-field-name>
>>
<cmr-field-type>java.util.Collection</cmr-field-type>
>>                </cmr-field>
>>            </ejb-relationship-role>
>>            <ejb-relationship-role>
>>
> <ejb-relationship-role-name>.....</ejb-relationship-role-name>
> 
>>                <multiplicity>Many</multiplicity>
>>                <relationship-role-source>
>>                    <ejb-name>MyBean</ejb-name>
>>                </relationship-role-source>
>>                <cmr-field>
>>                    <cmr-field-name>related</cmr-field-name>
>>                </cmr-field>
>>            </ejb-relationship-role>
>>        </ejb-relation>
>> 
>>public class MyKey implements Serializable{
>> 
>>    private String name;
>>    private Integer month;
>>    private Integer year;
>> 
>>    public MyKey(){
>>    }
>> 
>>    public MyKey(Integer year, Integer month, String name){
>>        this.name= name;
>>        this.month = month;
>>        this.year = year;
>>    }
>> 
>>    public String getName(){
>>        return name;
>>    }
>> 
>>    public Integer getMonth(){
>>        return month;
>>    }
>> 
>>    public Integer getYear(){
>>        return year;
>>    }
>> 
>>    public boolean equals(Object obj){
>>    }
>> 
>>    public int hashCode(){
>>        return getName().hashCode() ^ getYear().hashCode() ^ 
>>getMonth().hashCode();
>>    }
>>}
>> 
>>public abstract class MyBeanimplements EntityBean {
>> 
>>    public abstract MyKey getKey();
>>    public abstract Integer getYear();
>>    public abstract Integer getMonth();
>>   
>>    public abstract void setKey(MyKey key);
>>    public abstract void setYear(Integer year);
>>    public abstract void setMonth(Integer month);
>>   
>>    public abstract RelatedLocal getRelated();
>>    public abstract void setRelated(RelatedLocal related);
>> 
>>    public MyKey ejbCreate(Integer year, Integer month, String name)
>>            throws CreateException {
>> 
>>        MyKey key = new MyKey(year, month, name);
>>        setKey(key);
>> 
>>        setYear(year);
>>        setMonth(month);
>>        return null;
>>    }
>> 
>>    public void ejbPostCreate(Integer year, Integer month, String
name) {
>>                
>>        RelatedHomeLocal home = 
>>        RelatedLocal related = home.findByPrimaryKey(name);
>>        setRelated(related);
>>    }
>>    .....
>>}
>>
> 
> 
> 
> 
> -------------------------------------------------------
> Sponsored by:
> ThinkGeek at http://www.ThinkGeek.com/
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
> 
> 
> 
> This transmission contains information solely for intended recipient
and may
> be privileged, confidential and/or otherwise protect from disclosure.
If
> you are not the intended recipient, please contact the sender and
delete all
> copies of this transmission.  This message and/or the materials
contained
> herein are not an offer to sell, or a solicitation of an offer to buy,
any
> securities or other instruments.  The information has been obtained or
> derived from sources believed by us to be reliable, but we do not
represent
> that it is accurate or complete.  Any opinions or estimates contained
in
> this information constitute our judgment as of this date and are
subject to
> change without notice.  Any information you share with us will be used
in
> the operation of our business, and we do not request and do not want
any
> material, nonpublic information. Absent an express prior written
agreement,
> we are not agreeing to treat any information confidentially and will
use any
> and all information and reserve the right to publish or disclose any
> information you share with us.
> 
> 
> -------------------------------------------------------
> Sponsored by:
> ThinkGeek at http://www.ThinkGeek.com/
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user


-- 
xxxxxxxxxxxxxxxxxxxxxxxx
Dain Sundstrom
Chief Architect JBossCMP
JBoss Group, LLC
xxxxxxxxxxxxxxxxxxxxxxxx



-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user



This transmission contains information solely for intended recipient and may
be privileged, confidential and/or otherwise protect from disclosure.  If
you are not the intended recipient, please contact the sender and delete all
copies of this transmission.  This message and/or the materials contained
herein are not an offer to sell, or a solicitation of an offer to buy, any
securities or other instruments.  The information has been obtained or
derived from sources believed by us to be reliable, but we do not represent
that it is accurate or complete.  Any opinions or estimates contained in
this information constitute our judgment as of this date and are subject to
change without notice.  Any information you share with us will be used in
the operation of our business, and we do not request and do not want any
material, nonpublic information. Absent an express prior written agreement,
we are not agreeing to treat any information confidentially and will use any
and all information and reserve the right to publish or disclose any
information you share with us.


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Bringing you mounds of caffeinated joy.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to