-
1. Re: Bean lock error
adrian.brock Sep 10, 2003 6:19 AM (in response to smehta)As you say, check your equals() hashCode() and serialization
of the primary key. The check at deployment is very simple
and won't catch all errors.
Regards,
Adrian -
2. Re: Bean lock error
smehta Sep 10, 2003 6:59 AM (in response to smehta)Thank you for your response.
Here is My PK class
public class ContainerPK implements Serializable
{
public long ID = (long)0;
public ContainerPK()
{
this.ID = (long)0;
}
public ContainerPK(long Id)
{
this.ID = Id;
}
public int hashCode()
{
return (int)ID;
}
public boolean equals(Object other)
{
return ((other != null) && (other instanceof ContainerPK) && ((ContainerPK)other).ID == ID);
}
public String toString()
{
return String.valueOf(ID);
}
}
I have implemented the equals and hashcode method as above. Is there something else I need to do?
Thx again
jr -
3. Re: Bean lock error
adrian.brock Sep 10, 2003 8:13 AM (in response to smehta)That looks correct, it is usually the reason.
Do you have a simple test case that reproduces the problem?
I can tell you where you are going wrong.
Regards,
Adrian -
4. Re: Bean lock error
wolfie Sep 12, 2003 3:00 AM (in response to smehta)I also get exactly the same error message with JBOSS 3.2.2RC2 when using 1:1 CMR between two CMP beans with compound keys (all classes, including PKs and VOs, generated by XDoclet). All other CMR types seems to work just fine...
-
5. Re: Bean lock error
adrian.brock Sep 12, 2003 3:32 AM (in response to smehta)There was a bug fixed in 3.2.2RC3 the compound primary key
mapping of CMR fields where their order wasn't checked correctly.
Again post an example.
Regards,
Adrian -
6. Re: Bean lock error
wolfie Sep 12, 2003 7:36 AM (in response to smehta)Thanks for the answer!
My code looks like this (two EJBs referencing each other in a bi-directional 1:1 relationship):
SystemEJB.java:
/**
* Bi-directional 1:1 relation to SystemAdministrativeInformation
*
* @ejb.interface-method
*
* @ejb.relation
* name="System-SystemAdministrativeInformation"
* role-name="System-has-SystemAdministrativeInformation"
*
* @jboss.relation-mapping style="foreign-key"
*
* @jboss.relation
* fk-constraint="true"
* fk-column="PRId"
* related-pk-field="pRId"
* @jboss.relation
* fk-constraint="true"
* fk-column="SystemNumber"
* related-pk-field="systemNumber"
*/
abstract public SystemAdministrativeInformationLocal getSystemAdministrativeInformation();
abstract public void setSystemAdministrativeInformation(SystemAdministrativeInformationLocal v);
SystemAdministrativeInformationEJB.java:
/**
* Bi-directional 1:1 relation to System
*
* @ejb.interface-method
*
* @ejb.relation
* name="System-SystemAdministrativeInformation"
* role-name="SystemAdministrativeInformation-has-System"
*
* @jboss.relation-mapping style="foreign-key"
*
* @jboss.relation
* fk-constraint="true"
* fk-column="PRId"
* related-pk-field="pRId"
* @jboss.relation
* fk-constraint="true"
* fk-column="SystemNumber"
* related-pk-field="systemNumber"
*/
abstract public SystemLocal getSystem();
/**
* @ejb.interface-method
*/
abstract public void setSystem(SystemLocal v);
If I comment these code fragments out, there are no errors. Maybe I have missed something? The PK class (generated by XDoclet) consists of the fields pRId and systemNumber with corresponing column names PRId and SystemNumber in the DB. I will also try JBoss 3.2.2RC3 during the weekend to see if it fixes the problem...
/Ulf -
7. Re: Bean lock error
smehta Sep 12, 2003 7:43 AM (in response to smehta)Sorry for the late response.
I am still learning the ropes on JBoss 3.2.1 as I am relatively new. We were using Jboss 2.2 for the past year and half. Due to the improved performance in 3.0, we decided to upgrade to 3.2.1.
After making the necessary changes in ejb-jar.xml and jboss.xml, compiling our code with the new 3.2.1 classes, I started seeing these Bean Lock Error.
The same code though works correctly on JB2.2 and did we not see these errors because JBoss 2.2. did not enforce these rules that 3.2.1 enforces?
In the meantime, I shall dig around and post the code that throws this error.
thx
-jr -
8. Re: Bean lock error
smehta Sep 12, 2003 7:56 AM (in response to smehta)Hi Adrian:
Your mentioned that there was a bug fixed in 3.2.2RC3 that had something to do with compund primary keys.
Here is another one of my other primary key classes.
---------------------------------------------------------------
public class ContainerClassPK implements Serializable
{
public long TypeID;
public short CatID;
public ContainerClassPK()
{
TypeID = 0;
CatID = 0;
}
public ContainerClassPK(short catID, long typeID)
{
TypeID = typeID;
CatID = catID;
}
public int hashCode()
{
return (int)(TypeID ^ CatID);
}
public boolean equals(Object that)
{
return ((that == this) || ((that != null) && (that instanceof ContainerClassPK) &&
((ContainerClassPK)that).CatID == CatID && ((ContainerClassPK)that).TypeID == this.TypeID));
}
}
-------------------------------------------------------------
Would th exor operation in the hashCode method be a cause?
jr -
9. Re: Bean lock error
wolfie Sep 15, 2003 12:33 AM (in response to smehta)I have now tested JBoss RC3.2.2RC3 and the BeanLock errors seem to be gone. Once again, thanks for your advice! :)
/Ulf