-
1. Re: Primary Keys not created in mysql for compound CMP key
marcilgen May 8, 2002 11:58 PM (in response to stoffe)Did you ever hear back about how to do this? I'm running into the same problem.
I have an entity bean called RoomInfoBean and the primary key for this class is a class called RoomInfoPK. RoomInfoBean has several fields but two fields compose the primary key: String lobbyName and String roomName. RoomInfoPK just has the two fields lobbyName and roomName, which of course should map to the corresponding fields in the bean.
I am confused as to how to specify the findByprimaryKey method in jaws.xml. For a simple primary key, you can set <primkey-field> in ejb-jar.xml to be the primary key field, so in that case there is no need to specify a findByPrimaryKey method in jaws.xml. There it is clear how JBOSS will map the appropriate column in my database table to the bean field. But for my compound primary key, I can't use <primkey-field> in ejb-jar.xml. I can only use <prim-key-class> to tell JBOSS that I am using a primary key class of RoomInfoPK. So how does JBOSS know which two columns within my roominfo table in the database must be mapped to the two fields I need in my primary key? Some of the documentation says that findByPrimaryKey is generated automatically. But I don't see how it can do this for compound primary keys like this unless I somehow tell jaws to use (for example) the first column for lobbyName and the second column for roomName to build my primary key class. I'm guessing that I need to do this somehow, but I don't know how.
Anyone out there know the answer to this?