ObjectDB ObjectDB

Lazy loading does not work - crud takes long

#1

tomee7.0.0SNAPSHOT,objectdb 2.6.4

The OneToMany Entities are filled with 40.000 Records and they have between 20-40 Columns.

It takes over 50s to load all Project Enities that contains the OneToMany Relationships.

It should be load lazy but i dont know why the query fetch all the Data.


@PostConstruct
    public void init() {
        com.objectdb.Enhancer.enhance("com.**.Project,com.**.Datapoint,com.**.Advalm);
        long t0 = System.currentTimeMillis();
        projects = service.getResultList();
        Logger.getLogger(TableManager.class.getName()).log(Level.INFO, "initialize projects takes {0} s", (System.currentTimeMillis() - t0) / 1000);
    }

Bean.class

public List<Project> getResultList() {
        Query query = em.createQuery("SELECT q FROM Project q", Project.class);
        return query.getResultList();
    }

Query.class


@Entity

@Table(name = "PROJECT")

@SequenceGenerator(name = "PROJECT_SEQUENCE", sequenceName = "PROJECT_SEQUENCE", allocationSize = 1, initialValue = 0)

@SuppressWarnings({"PersistenceUnitPresent", "ValidAttributes"})
public class Project implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROJECT_SEQUENCE")
    private Long id;
    ..
    ..
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy="project",fetch = FetchType.LAZY)
    private List<Datapoint> datapoint;
   
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy="project",fetch = FetchType.LAZY)
    private List<Advalm> advalm;


Entity.class

 

On the other side if i remove all items from the OneToMany Relation at Example Datapoint (10.000 Recors).

The API need for 50 Records 1 second to remove.

for(Datapoint d: list){ em.remove(em.merge(d))}

 

edit
delete
#2

The class definitions including the lazy settings look fine.

Examining why eager load is used in your application will require posting a minimal Java console test case (see these instructions) that reproduces this situation.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.