You are missing a field annotated with @Id
. Each @Entity
needs an @Id
– this is the primary key in the database.
If you don’t want your entity to be persisted in a separate table, but rather be a part of other entities, you can use @Embeddable
instead of @Entity
.
If you want simply a data transfer object to hold some data from the hibernate entity, use no annotations on it whatsoever – leave it a simple pojo.
Update: In regards to SQL views, Hibernate docs write:
There is no difference between a view and a base table for a Hibernate mapping. This is transparent at the database level
Related Posts:
- How to fix the Hibernate “object references an unsaved transient instance – save the transient instance before flushing” error
- How to fix the Hibernate “object references an unsaved transient instance – save the transient instance before flushing” error
- Hibernate problem – “Use of @OneToMany or @ManyToMany targeting an unmapped class”
- What’s the difference between JPA and Hibernate?
- How to map a composite key with JPA and Hibernate?
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed
- How to fix org.hibernate.LazyInitializationException – could not initialize proxy – no Session
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- How does spring.jpa.hibernate.ddl-auto property exactly work in Spring?
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- PersistentObjectException: detached entity passed to persist thrown by JPA and Hibernate
- What is the exact meaning of the JPA @Entity annotation?
- Hibernate show real SQL
- What is an ORM, how does it work, and how should I use one? [closed]
- What is the difference between an ORM and an ODM?
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- issue ORA-00001: unique constraint violated coming in INSERT/UPDATE
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘MyController’:
- C++ identifier is undefined
- No more data to read from socket error
- What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?
- Unable to create requested service [org.hibernate .engine.jdbc.env.spi.JdbcEnvironment]-MySQL
- What is the meaning of single and double underscore before an object name?
- Spring Data JPA Update @Query not updating?
- What’s the difference between session.persist() and session.save() in Hibernate?
- What’s the advantage of load() vs get() in Hibernate?
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- What Java ORM do you prefer, and why?
- What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do
- sequelize “findbyid” is not a function but apparently “findAll” is
- No Persistence provider for EntityManager named
- What is the “N+1 selects problem” in ORM (Object-Relational Mapping)?
- How to call on a function found on another file?
- Hibernate Error: a different object with the same identifier value was already associated with the session
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- org.hibernate.exception.SQLGrammarException: could not extract ResultSet
- hibernate properties not found
- Conversion of a datetime2 data type to a datetime data type results out-of-range value
- SQL Error: 0, SQLState: 08S01 Communications link failure
- Advice on loopback.js vs express js
- Hibernate dialect for Oracle Database 11g?
- What kind of Java type is “[B”?
- Hibernate – Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
- JPA or JDBC, how are they different?
- Spring Hibernate – Could not obtain transaction-synchronized Session for current thread
- Spring Boot – Cannot determine embedded database driver class for database type NONE