Errors in generated code

jfi <[email protected]> Sat, 12 Mar 2005 00:26:05 +0100
Newsgroups gmane.comp.java.ejb.middlegen.user
Message-ID <[email protected]>
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



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click