[Liferay 学习笔记]PRUser 中的prUser.setGender("");方法找不到的原因

在跟着Liferay in Action学习的时候,仿照示例代码进行模拟实现时遇到一个问题:从service.xlm运行Build Service后生成的PRUser中找不到该项,到底是怎么回事呢?读示例源代码时在Interface  PRUser中看到了该项的定义,但是根据规范 PRUser中是不建议开发者直接编辑该接口的。

最后查找资料找到原因了:

1、Gender属性是不持久化的实体属性,所以在service.xml中没有定义。

2、这种不持久化的实体属性需要在-Impl类中添加代码,然后运行Build Service后工具会自动抽取并更新接口中的定义。

 

我获得帮助的地址:

http://www.manning-sandbox.com/thread.jspa?threadID=42504

Hi,
The setGender() method does indeed exist. It's in PRUserImpl.java. Remember, the -Impl classes are the only places that you can add your own code. Anything you add there, the next time Service Builder is run, it propagates those methods to the interface and the rest of the class hierarchy. So the gender field becomes a non-persistent field in your model layer.
Hope this helps!
--Rich

posted @ 2012-10-12 08:44  MichaeL  阅读(280)  评论(0编辑  收藏  举报