如何使用 EnityHome 持久方法在 SEAM 中持久保留子实体?
我有两个具有一对一关系的实体,即映射到其特定表上的 Customer 和 CustomerDetails。
我在页面中有一个表单,用于捕获每个实体属性的每个值。
我该如何在 SEAM 中保留这个? 因为我的命令按钮仅指向一个操作方法,而 CustomerHome.persist()
我所做的是将表单中的值分配给 CustomerDetails 的属性,
value="#{customerHome.intance.customerDetails.address}"
但我收到了 customerDetails 解析为 null 的错误。
另一个解决方法是在我的 CustomerHome 持久方法中有两个持久方法来持久保存两个实体,但我收到另一个错误,必须在调用保存之前首先分配 CustomerDetails 的 ID。
有谁可以向我解释一下这件事吗? 我是全新的SEAM。
I have two entity with a relationship of one-to-one namely Customer and CustomerDetails mapped on their specific tables.
I have a form in the page that captures each values to the property of each Entity.
How am i going to persist this in SEAM?
since my command button only points to one action method which the CustomerHome.persist()
What i did is to assign the value in my form to the property of CustomerDetails like
value="#{customerHome.intance.customerDetails.address}"
but i am getting error that customerDetails resolve to null.
another work arround is to have two persist method in my CustomerHome persist method that persist both entities but i am getting another error that the ID of the CustomerDetails must be assign first before call to save.
Is there anyone who can make this things clear to me?
I am completely new SEAM.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你用seam-gen吗?
尝试查看seam-gen生成的项目
他们使用“wire”方法来初始化关系。
基本上在创建实例时,您确保所有关系都指向各自的 fooHome.instance 对象。
然后在持久方法中,您首先调用关系的 EntityHome 的持久方法。
Do you use seam-gen?
Try to look at project generated by seam-gen
They use a "wire" method to initialize relations.
Basically on creating your instance you make sure that all relations point to their respective fooHome.instance objects.
Then in your persist method you call first the persist method of the relation's EntityHome.
如果您直接从 IDE 复制该代码,那么拼写错误可能是导致问题的原因:
应该是
If you've copied that code directly from your IDE, then the typo is probably the cause of your problems:
should be