关于Toplink抓取政策
我正在为一个 Swing 项目工作,所使用的技术是带有 Toplink 必需品的 netbeans、mysql。
我面临的问题是在调用外键属性的 getter 集合时进行插入后实体对象不会更新。
例如:我有 2 个表 Table1、Table2。我有 sno 列,id 列作为 Table1 & 中的主键是表2中的外键。通过 find 方法,我只是获取特定的 sno 对象(表 1 中存在),并将一些值保留到 table2 和 table2 中。已提交交易。
当我通过 find 方法 & 选择相同的 sno 对象时通过 bean 的 getTable2Collection() 从 Table2 获取其集合(因为它已经由 toplink Essential 在 bean 中创建),除了显示它的所有其他记录之外,我无法获取最新添加的记录。关闭应用程序后,打开它,然后在通过上述过程调用相同的 sno 时会反映新记录。
我开始知道这是一种惰性获取,应该有某种方式来更改获取策略以使实体对象随着更改而更新。所以请在这方面帮助我。
问候,
昌杜
I'm working for a Swing Project and the technologies used are netbeans with Toplink essentials, mysql.
The Problem I'm facing is the entity object dosn't get updated after insertions take place while calling a getter collection of the foreign key property.
Ex: I have 2 tables Table1,Table2. I have sno column, id column as a primary key in Table1 & is Foreign Key in Table2. Through find method I just get the particular sno object(existed in table 1) set some values persisted to table2 & committed the transaction.
When I select the same sno object through find method & gets its collection from Table2 through the getTable2Collection() of the bean(as it is already created in bean by toplink essential) I'm unable to get the latest added record except that all other records of it are displayed. After I close the application & opening it then the new record gets reflected while calling the same sno through the above process.
I came to know that this is a kind of lazy fetching and there should be some way of fetch policy to be changed to make the entity object get updated with the changes. So Please help me in this regard.
Regards,
Chandu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只想尝试急切获取,您可以在注释中指定获取方法(如果您使用注释),它看起来像......
If you just want to try eager fetching you can specify the fetch method in your annotations (if you're using annotations) and it would look something like...