I wrote a simple entity bean ResourceOwnerEJB with ResourceOwnerPK primary key
class. The bean contains two fields: username and password. The primary key class
contains the only field: username. When deployed, I can create instances of the bean
successufully.
Here is the log:
INFO [com.imedia.tracker.components.resourceowner.bean.ResourceOwnerEJB] Created:
{username=owner1 password=password1}
DEBUG[org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner] Create:
pk=[.owner1.] <-- CORRECT VALUE
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner] Executing
SQL: SELECT COUNT(*) FROM ResourceOwner WHERE username=?
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner] Executing
SQL: INSERT INTO ResourceOwner (username, password) VALUES (?, ?)
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner] Create:
Rows affected = 1
Then I wrote UserPK primary key class that is the same as ResourceOwnerPK (contains
only the field username). The only thing I changed in ResourceOwnerPK is replacement
of 'extends Object' with 'extends UserPK'. When deployed I can't create an instance of
the bean.
Here is the log:
INFO [com.imedia.tracker.components.resourceowner.bean.ResourceOwnerEJB] Created:
{username=owner1 password=password1}
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner] Create:
pk=[.null.] <-- NULL !!!
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner] Executing
SQL: SELECT COUNT(*) FROM ResourceOwner WHERE username=?
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner] Executing
SQL: INSERT INTO ResourceOwner (username, password) VALUES (?, ?)
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner] Create:
Rows affected = 1
ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException, causedBy:
java.lang.NullPointerException
at
com.imedia.tracker.components.resourceowner.interfaces.ResourceOwnerPK.hashCode(ResourceOwnerPK.java:59)
Here is hashCode function (the same in UserPK and ResourceOwnerPK):
public int hashCode() {
if( _hashCode == Integer.MIN_VALUE )
_hashCode += this.username.hashCode(); // line 59
return _hashCode;
}
Do someone have some thoughts on why it is happening? Any advices are
very much appreciated.
TIA!
Environment: JBoss-3.1.0alpha, J2SDK1.4.0, Win2000
--
Best regards,
Alex Loubyansky mailto:[EMAIL PROTECTED]
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user