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

Reply via email to