简体   繁体   English

关于Toplink提取政策

[英]Regarding Toplink Fetching Policy

I'm working for a Swing Project and the technologies used are netbeans with Toplink essentials, mysql. 我正在为一个Swing项目工作,使用的技术是带有Toplink要点的mysql的netbeans。

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. 我面临的问题是,在调用外键属性的getter集合进行插入后,实体对象不会得到更新。

Ex: I have 2 tables Table1,Table2. 例如:我有2个表Table1,Table2。 I have sno column, id column as a primary key in Table1 & is Foreign Key in Table2. 我在表1中有sno列,id列作为主键,而在表2中是外键。 Through find method I just get the particular sno object(existed in table 1) set some values persisted to table2 & committed the transaction. 通过find方法,我只是获得特定的sno对象(存在于表1中),将一些值持久化到table2并提交了事务。

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. 当我通过find方法选择相同的sno对象并通过bean的getTable2Collection()从Table2中获取其集合时(因为toplink必不可少的它已经在bean中创建了),除了所有其他记录,我无法获取最新添加的记录显示它的记录。 After I close the application & opening it then the new record gets reflected while calling the same sno through the above process. 在我关闭并打开应用程序后,新记录会反映出来,同时通过上述过程调用相同的sno。

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 昌都

如果您只想尝试快速获取,可以在批注中指定fetch方法(如果您使用的是批注),它将看起来像...

@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM