Seam-gen creates code which will not compile for multiple foreign keys (mysql)
------------------------------------------------------------------------------
Key: JBSEAM-3920
URL:
https://jira.jboss.org/jira/browse/JBSEAM-3920
Project: Seam
Issue Type: Bug
Affects Versions: 2.1.1.GA
Reporter: philip andrew
The bug is described at forum reference. Duplicate description is below.
Hi,
I have two mysql tables, user and staff. On my user table I have three foreign keys,
social_security_assistance_confirmed_by_staff_id, approved_by_staff_id,
rejected_by_staff_id, all reference staff.id.
I seam-gen with seam generate-entities and one problem is it makes my UserHome class wrong
with:
@Name("userHome")
public class UserHome extends EntityHome<User> {
@In(create = true)
StaffHome staffHome;
@In(create = true)
StaffHome staffHome;
@In(create = true)
StaffHome staffHome;
That does NOT compile, how come it generates this? Everything is ok if I delete the
multiples and cut it down to one.
Here are the mysql tables
CREATE TABLE `staff` (
`id` int(10) NOT NULL auto_increment,
`user` varchar(80) collate utf8_unicode_ci NOT NULL,
`password` varchar(80) collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
CREATE TABLE `user` (
`id` int(10) NOT NULL auto_increment,
`user` varchar(80) collate utf8_unicode_ci NOT NULL,
`password` varchar(80) collate utf8_unicode_ci NOT NULL,
`first_name_chinese` varchar(80) collate utf8_unicode_ci default NULL,
`last_name_chinese` varchar(80) collate utf8_unicode_ci default NULL,
`first_name_english` varchar(80) collate utf8_unicode_ci default NULL,
`last_name_english` varchar(80) collate utf8_unicode_ci default NULL,
`hk_id_number` varchar(20) collate utf8_unicode_ci NOT NULL,
`date_of_birth` date NOT NULL,
`contact_phone_number` varchar(20) collate utf8_unicode_ci default NULL,
`email` varchar(80) collate utf8_unicode_ci NOT NULL,
`address` varchar(255) collate utf8_unicode_ci default NULL,
`school` varchar(80) collate utf8_unicode_ci default NULL,
`social_security_assistance_indicated` tinyint(1) NOT NULL,
`social_security_assistance_confirmed` tinyint(1) NOT NULL default '0',
`social_security_assistance_confirmed_by_staff_id` int(10) default NULL,
`date_signed` date default NULL,
`approved_by_staff` tinyint(1) NOT NULL default '0',
`approved_by_staff_id` int(10) default NULL,
`rejected_by_staff` tinyint(1) NOT NULL default '0',
`rejected_by_staff_id` int(10) default NULL,
`blacklist` tinyint(1) NOT NULL default '0',
`created` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`updated` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
UNIQUE KEY `user` (`user`),
UNIQUE KEY `hk_id_number` (`hk_id_number`),
UNIQUE KEY `email` (`email`),
KEY `social_security_assistance_confirmed_by_staff_id_idxfk`
(`social_security_assistance_confirmed_by_staff_id`),
KEY `approved_by_staff_id_idxfk` (`approved_by_staff_id`),
KEY `rejected_by_staff_id_idxfk` (`rejected_by_staff_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
ALTER TABLE `user`
ADD CONSTRAINT `user_ibfk_3` FOREIGN KEY (`rejected_by_staff_id`) REFERENCES `staff`
(`id`),
ADD CONSTRAINT `user_ibfk_1` FOREIGN KEY
(`social_security_assistance_confirmed_by_staff_id`) REFERENCES `staff` (`id`),
ADD CONSTRAINT `user_ibfk_2` FOREIGN KEY (`approved_by_staff_id`) REFERENCES `staff`
(`id`);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira