About PersistenceUtil isLoaded in ToyApplication

Moderator: admin

Post Reply
himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

About PersistenceUtil isLoaded in ToyApplication

Post by himaiMinh » Tue Aug 30, 2016 3:45 pm

Hi,
In the ToyApplication, Item.java,

Code: Select all

public String toString() {
        PersistenceUtil pu = Persistence.getPersistenceUtil();
        return "salesapp.Item[id=" + id + " name="+name+
               " categories="+(pu.isLoaded(categories)?categories:"Not Loaded")+
                "]";
     }
Why the PersistenceUtil cannot load categories ?
How can I make it load categories?

admin
Site Admin
Posts: 8621
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About PersistenceUtil isLoaded in ToyApplication

Post by admin » Tue Aug 30, 2016 9:27 pm

Just set fetch type to eager in Item.java for categories:

@ManyToMany(fetch=FetchType.EAGER)
private Set<Category> categories;
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest