Is it a problem to access a Hibernate entity getter in a for loop?

We got some performance issues with a statement and I don’t know why.

First of all, you only mentioned you have a performance problem but did not explain what exactly does the performance problem consist of.

If inside the for-loop you are accessing some lazy associations of the Address entity, then you might have bumped into a N+1 query issue which can be easily fixed using a JOIN FETCH directive.

The call employee.getAddresses loads data into the employee object. is it ok to use this Statement within a for Loop? or does it cause Performance issues? And why?

List addresses = employee.getAddresses(); <-- hibernate call outside of foor loop
for (Address : addressess) {
    // do something…
}

There is no difference. The foreach loop calls the right-hand argument only once at the beginning of the loop, so there will be a single employee.getAddresses() call.

Whenever you have a performance issue in your data access layer, the first thing you need to do is to check the SQL query log and see what statements are executed.

Check out this article about the best way to log SQL statements with JDBC, JPA or Hibernate.