• Home
  • spring boot an @manytoone references an unknown entity: java.util.list

spring boot an @manytoone references an unknown entity: java.util.list

It sounds like you are trying to create a @ManyToOne relationship between two entities in a Spring Boot application, but you are encountering an error message stating that “a different object with the same identifier value was already associated with the session.” This error usually occurs when you are trying to persist an entity that is already associated with a different Session object in your application.

To fix this error, you need to make sure that you are using the same Session object to persist all the entities that are related to each other. You can do this by using a single SessionFactory to create a Session for each request, and then closing the Session after you are done with it. You can also use the @Transactional annotation to manage your Session objects automatically.

Alternatively, you can try detaching the entity from the current Session before persisting it. You can do this by calling the evict() method on the Session object, or by using the detach() method on the EntityManager object.

It’s also possible that the error is caused by a problem with your database configuration or schema. Make sure that your database is configured correctly and that your entities are mapped to the correct tables and columns.

I hope this helps! If you have any further questions or need more specific help, feel free to ask.