I am wondering what the correct solution to this situation is. The method is running in a transaction. I a remove the first line of this method I will get detached entity passed to persist exception. I understand the problem. The Company is not in the persistence context.
Is the code below the only solution? Is it better way?
@Override
public void delete(Company company) {
company = companyDao.get(company.getId(), CompanyLoadParameter.LOAD_LANGUAGES);
companyDao.delete(company);
}
Where Company.K_id is the Java property name (as a string) for the Primary Key.
I do things this way as the HQL can be refactored using standard IDE tooling and probably continue the work afterwards.
URL on HQL https://docs.jboss.org/hibernate/orm/3.5/reference/en/html/queryhql.html