[jboss-user] [EJB/JBoss] - problem with new bean I'm creating (EJB2.0)

MikePhoenix do-not-reply at jboss.com
Tue Dec 2 14:30:55 EST 2008

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

anonymous wrote : 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

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.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4193845#4193845

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4193845

More information about the jboss-user mailing list