Hey all.
assume we have two CMP beans TeamBean, PlayerBean
the relationship is one to many and bidirectional.
TeamBean has the following CMP fields:
name, city
TeamBean has setter and getter methods for these fields.
the database schema for TeamBean is :
NAME, CITY
PlayerBean has the following CMP fields :
id, email
PlayerBean has setter and getter methods for these fields.
the database schema for PlayerBean is :
ID, EMAIL, TEAM (TEAM is FK)
I have the following code (in a facade bean):
| public void addPlayer(id, name, String team) {
| LocalPlayer lp = playerHome.create(id, name);
| LocalTeam lt = teamHome.findByPrimayKey(team);
| lp.setTeamLocal(lt);
| }
|
the container will insert "a right" value at TEAM column of Player table.
but I have read some articles that said :
we should a CMP field called team in PlayerBean and create setter and getter methods
for this CMP field.
this is because (as the article says), we want to create a transfer object for
PlayerBean with these fields :
id, email, team
so we able to write :
| new PlayerDO(local.getID( ), local.getEmail( ), local.getTeam( ));
|
in my case (which I didn't create getTeam( )), I can write :
| new PlayerDO(local.getID( ), local.getEmail( ), local.getTeamLocal( ).getName( ));
|
what is the right approach ??
as far as I know, if we create a method like setTeam( ), this may damage the mapping
that has been done by the container.
should I create a CMP field called team and create setter and getter methods for it ?
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3849785#3849785
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3849785
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user