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))}