Hi,
I have a situtation where I have a MySQL table with the following primary key definition
CREATE TABLE iitem (
`rID` BIGINT NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL default '',
`createdDate` timestamp NOT NULL default CURRENT_TIMESTAMP ,
`createdByID` decimal(10,0) NOT NULL default '1',
`lastModifiedDate` timestamp NOT NULL default '2005-01-01 12:00:00',
`lastModifiedByID` decimal(10,0) NOT NULL default '1',
`sID` varchar(255) NOT NULL default '',
`ownerID` decimal(10,0) NOT NULL default '1',
`parentID` decimal(10,0) default null,
`layoutID` decimal(10,0) default null,
`description` varchar(100) default '',
`securityPolicyID` decimal(10,0) default null,
`itemWorkspaceID` decimal(10,0) default null,
`itemProjectID` decimal(10,0) default null,
`isSecurityPolicyInherited` tinyint(4) default '0',
`contentType` varchar(30) not null default '',
`numberOfChildren` decimal(10,0) default 0,
PRIMARY KEY (`rID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
In the xml file the column is declared as follows:
<id name="id" type="long">
<column name="RID" sql-type="bigint" not-null="true"/>
<generator class="increment"/>
</id>
The column is inserted perfectly with this line of code:
workspaceDAO.makePersistent(workspace);
which does
public void makePersistent(Workspace item) throws InfrastructureException {
try {
HibernateUtil.getSession().saveOrUpdate(item);
} catch (HibernateException ex) {
throw new InfrastructureException(ex);
}
}
I am expecting that after the makePersistent method is finished, the workspace object will have the id column populated with the newly generated primary key. However all I get is 0. Does anyone know why?
|