0 Replies Latest reply: Dec 2, 2008 2:32 PM by Michael Phoenix RSS

problem trying to create new bean (EJB2.0)

Michael Phoenix Newbie

I'm trying to create a new entity bean for an existing application. When I deploy I get the following error:

org.jboss.deployment.DeploymentException: Field changeDate in prim-key-class must be of the same type.


New table sql
CREATE TABLE `projecthistory` (
 `ProjectId` int(11) NOT NULL default '0',
 `ChangeDate` datetime NOT NULL,
 `UserID` varchar(50) NOT NULL,
 `Status` int(11) NOT NULL default '0',
 PRIMARY KEY (`ProjectId`, `ChangeDate`),
 KEY `projecthistory_ProjectID_FK` (`ProjectId`),
 CONSTRAINT `projecthistory_ProjectID_FK` FOREIGN KEY (`ProjectId`) REFERENCES `projects` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
);


prim-key in ejb-jar.xml
<prim-key-class>lingonet.projecthistory.ProjectHistoryKey</prim-key-class>


The key class
public class ProjectHistoryKey {
 public Integer projectID;
 public Date changeDate;

 public ProjectHistoryKey (Integer projectID, Date changeDate) {
 this.projectID = projectID;
 this.changeDate = changeDate;
 }
}


I am using java.util.date in my java code, which works for other beans where the date isn't a primary key? Do I need to use java.sql.date or is there just a problem using dates in primary keys or something else entirely? Some guidance here would be appreciated.

Mike