I am getting error:
Exception in thread \"main\" org.hibernate.HibernateException:
Could not obtain transaction-synchronized Session for current thread
The error org.hibernate.MappingException: Unknown entity: ProductPart
indicates there is no entity with name ProductPart
. One way to fix this issue is to pass the Class
object to createCriteria
method as:
createCriteria(ProductPart.class)
From API the difference in using String and Class is as follows:
Session.createCriteria(String)
Create a new Criteria instance, for the given entity name.
Session.createCriteria(Class)
Create a new Criteria instance, for the given entity class, or a superclass of an entity class, with the given alias.
If you pass a String then hibernate looks for an entity whose name is declared as ProductPart
.