Discussion:
[Middlegen-user] Errors in generated code
jfi
2005-03-11 21:26:38 UTC
Permalink
Using middlegen 2.1 with mssql i'm experiencing some problems when
generating the Bean code. I've created two test tables illustrating it:

CREATE TABLE accesslevel (
accesslevelid int NOT NULL default '0',
accesslevelname varchar default NULL,
PRIMARY KEY (accesslevelid)
);


CREATE TABLE userrolemoduleprofile (
roleid int NOT NULL default '0',
accessmoduleid int NOT NULL default '0',
accesslevelid int NOT NULL default '0',
PRIMARY KEY (roleid,accessmoduleid,accesslevelid),
CONSTRAINT fk_userrolemoduleprofile_accesslevel FOREIGN KEY
("accesslevelid") REFERENCES accesslevel ("accesslevelid")
);

NB! The PK of userrolemoduleprofile are all both PK and FK's.
MIddlegen generates the following code for the AccessLevelBean.java:
-------------------------------------------------------------------
/**
* The container invokes this method immediately after it calls
ejbCreate.
*
* @param accesslevelname the accesslevelname value
*/

public void ejbPostCreate( java.lang.String accesslevelname ) throws
javax.ejb.CreateException {
// Set CMR fields
setUserrolemoduleprofiles(userrolemoduleprofiles);
}
---------------------------------------------------------------
This is of course not correct and will not compile.
But if I set the accesslevelname NOT to accept NULL values, then no
setUserrolemoduleprofiles(userrolemoduleprofiles) method are generated
and things compile...
The setUserrrolemoduleprofiles() method in accesslevel are now never
called (i dont think i need it anyhow)...so i'm not sure of the meaning
of that. Anyhow; i cant change all non fk,pk columns to NOT NULL, so I'm
a little unsure what to do right now.
Any light on this?

-Jon
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.7.1 - Release Date: 09.03.2005
Loading...