I am using MySQL 5.5 and hibernate 3. I have created a view in my database and also created an entity corresponding to it using salto db generator. When I try to execute my code the bean creation for session factory fails giving me the following error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘SessionFactory’ defined in class path resource [persistence-context.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.viewer.common.entity.ViewEntity
So I ask, if we need primary key for creating entities???
Yes, every entity needs id. Does not matter is it mapped to the view or not. Maybe in your view there is some combination of columns (composite key) that can be used as id?