2

I am seeing two entity instance for each record in Db, when I am profiling the application using JProfiler.

Say for example Global_message is my table name and it has 20 records, the mapped JPA entity shows 40 instance [2 Classes] in Jprofiler.

Can someone help with this? Is this the expected behavior?

I am loading all the tables into cache on server start up and I am seeing this behavior on server start up.

hop
  • 2,518
  • 11
  • 40
  • 56

1 Answers1

2

That is perfectly normal. Hibernate needs other instance to check is the entity instance operated by application dirty (is it modified). On the moment when session is flushed Hibernate checks possible changes against other instance. For further details about dirty-check this question does have good answer.

Community
  • 1
  • 1
Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135
  • Thanks. I have a justification now! Is there any way to tell to avoid this. Because, I am just reading these values and never-ever modify them. – hop Nov 29 '12 at 20:05
  • 1
    EclipseLink allows you to annotate your Entity with an EclipseLink-specific annotation (@org.eclipse.persistence.annotations.ReadOnly) that prevents this type of cloning. Maybe Hibernate has something similar. – Brian Vosburgh Nov 30 '12 at 17:03