Wow... I can't understand it. After modifying hashCode() in both
ResourceOwnerPK and UserPK classes to just calling super.hashCode(), I
can create an instance but the log is as follows:
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 BUT CREATED WITHOUT EXCEPTION AND DB CONTAINS 'owner1'
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
INFO [com.imedia.tracker.components.resourceowner.bean.ResourceOwnerEJB] Created
(postCreate): pk is [.null.]
AL> 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:
AL> username. When deployed, I can create instances of the bean successufully.
AL> Here is the log:
AL> INFO [com.imedia.tracker.components.resourceowner.bean.ResourceOwnerEJB] Created:
{username=owner1 password=password1}
AL> DEBUG[org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner]
Create: pk=[.owner1.] <-- CORRECT VALUE
AL> DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner]
Executing SQL: SELECT COUNT(*) FROM ResourceOwner WHERE username=?
AL> DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner]
Executing SQL: INSERT INTO ResourceOwner (username, password) VALUES (?, ?)
AL> DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner]
Create: Rows affected = 1
AL> 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
AL> 'extends UserPK'. When deployed I can't create an instance of the bean.
AL> Here is the log:
AL> INFO [com.imedia.tracker.components.resourceowner.bean.ResourceOwnerEJB] Created:
{username=owner1 password=password1}
AL> DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner]
Create: pk=[.null.] <-- NULL !!!
AL> DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner]
Executing SQL: SELECT COUNT(*) FROM ResourceOwner WHERE username=?
AL> DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner]
Executing SQL: INSERT INTO ResourceOwner (username, password) VALUES (?, ?)
AL> DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.ResourceOwner]
Create: Rows affected = 1
AL> ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException,
causedBy:
AL> java.lang.NullPointerException
AL> at
com.imedia.tracker.components.resourceowner.interfaces.ResourceOwnerPK.hashCode(ResourceOwnerPK.java:59)
AL> Here is hashCode function (the same in UserPK and ResourceOwnerPK):
AL> public int hashCode() {
AL> if( _hashCode == Integer.MIN_VALUE )
AL> _hashCode += this.username.hashCode(); // line 59
AL> return _hashCode;
AL> }
AL> Do someone have some thoughts on why it is happening? Any advices are
AL> very much appreciated.
AL> TIA!
AL> 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