Seeing the continuing discussion, perhaps my reply didn't make it through the list?
David Nielsen <mailto:[EMAIL PROTECTED]> once said: > I have 2 EJB's > > 1. LanguageBean > 2. DVDRegionCodesBean > > in LanguagesBean i have: Is it LanguageBean or LanguagesBean? You refer below to Languages mostly, so I'll assume that and go forward... > public abstract DVDRegionCodesLocal getDVDRegion(); You might want to call this getDVDRegionCodes to be consistent. > i then ty to make a finder that finds all Languages the have a > specific regioncode. eks: region 2 > > i then creates the folowing xdoclet @ejb:finder comment: > > * @ejb:finder > * signature= "java.util.Collection > findByDVDRegion(java.lang.Integer dvdRegion)" > * query ="SELECT OBJECT(l) FROM Languages AS > l,IN(l.DVDRegion) AS r > WHERE r = ?1" > > and whats wrong... You're trying to do "WHERE DVDRegionCodes = 2". What you want instead is to find the DVDRegionCodes whose "code" (or whatever you called it) attribute is "2": * query="SELECT ... AS r WHERE r.code = ?1" Here, r.code is the CMP attribute in DVDRegionCodes that maps to the region code on which you are searching. If this also happens to be the primary key of the DVDRegionCodes table (I recommend you *do not* do this, but that's a different matter; look up references on "surrogate keys" for the arguments for/against using data as primary keys), then change "r.code" to "r.regionCode". You could, however, remove the IN clause (and thus the SQL join) entirely. Simply map the foreign key Languages.DVDREGION to a CMP attribute and you'll be able to search on it. This is how I have mapped all of my N:1 relations. I create the CMR and a matching CMP to the foreign key. See below for an example from an entity bean with a N:1 relation to the User bean. Once you map the foreign key DVDREGION to, say, dvdRegion, you can use this as your finder: query = "SELECT OBJECT(l) FROM Languages AS l WHERE l.dvdRegion = ?1" Good luck! ------------ 8< ------------------------------------------- 8< ------------ // From BuProfile bean with unidirectional N:1 relation to User bean. // RELATION /** * @ejb.interface-method * view-type="local" * @ejb.transaction type="Supports" * @ejb.relation * name="User-BuProfile" * role-name="BuProfiles-have-a-User" * cascade-delete="yes" * target-ejb="User" * target-role-name="User-has-many-BuProfiles" * target-cascade-delete="no" * target-multiple="yes" * @weblogic.column-map * foreign-key-column="user_id" * key-column="id" */ public abstract UserLocal getUser ( ) ; public abstract void setUser ( UserLocal user ) ; // FOREIGN KEY /** * @ejb.interface-method * @ejb.transaction type="Supports" * @ejb.persistence * column-name="user_id" */ public abstract Integer getUserId ( ) ; public abstract void setUserId ( Integer userId ) ; /** * Attaches this BuProfile to the user with the given ID. * * @param userId unique ID of the owning user */ protected void setLocalUserId ( Integer userId ) throws UserNotFoundException { try { setUser(UserUtil.getLocalHome().findByPrimaryKey(userId)); } catch ( NamingException e ) { throw new ServiceException("Failure looking up user home object", e); } catch ( ObjectNotFoundException e ) { throw new UserNotFoundException(userId.toString()); } catch ( FinderException e ) { throw new ServiceException("Failure finding a user", e); } } David Harkness Sr. Software Engineer Sony Pictures Digital Networks (310) 482-4756 ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
