Do we always need an identifier when creating a sleep object? even if I create an entity from a view?

I am using MySQL 5.5 and hibernate 3. I created a view in my database and also created an object corresponding to it using the salto db generator. When I try to execute my code, creating a bean for a factory session does not give me the following error

org.springframework.beans.factory.BeanCreationException: an error occurred while creating a bean with the name "SessionFactory" defined in the key path resource [persistence-context.xml]: the init method call failed; The nested exception is org.hibernate.AnnotationException: The identifier is not specified for the object: com.viewer.common.entity.ViewEntity

So, I ask if we need a primary key to create objects ???

+4
source share
1 answer

Yes, every object needs an id. It does not matter if it is mapped to a view or not. Maybe, in your opinion, there is some combination of columns (composite key) that can be used as id?

+4
source

All Articles