简体   繁体   中英

Regarding Toplink Fetching Policy

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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