请教,CMR怎么用?
刚开始学还没搞明白,有了两个cmp,设好了cmr-field,可是怎么用呀?
比如有两个表
create table books(
int id primary key,
vchar(10) book_title,
int publisher_id foreign key reference publishers.id
)
create table publishers(
int id primary key,
vchar(10) pubisher_name
)
比如我想创建一条记录,通过输入books.id, book_title,publisher_name实现
是不是要自己写一个ejbcreate方法?在方法里先找到publisher_name对应的出版商id,再把三条信息插入到books表中?
谢谢帮忙^_^
推荐阅读
cmr是container manage relationship.如果你想使用cmr,首先确定你必须是ejb2.0或者以上
然后在ejb规范中cmr-field是不允许被操作的,ejbcreat()里面也不能操作,也就是如果你的publicsher_id是not null,基本上你的程序就没法子运行了,至少home.create()是甭想。
再次你设置关联关系的时候不是setpublicherid( intvalue),而是setpublishers( publishersobject)
先a = ahome.create()
然后b = bhome.create()
再a.setb(b)


讨论区