Is possible to have a Composite Primary Key which components are entity foreign keys?

I have the following model: (…) @IdClass(BetID.class) //Primary Key, composite = userID+gameID public class Bet { (…) //Primary Key @ManyToOne @Id private User user; //Composite key:userID @ManyToOne @Id private Game game; //Composite key:gameID In which, of course, has the following Composite key: public class BetID implements Serializable { @OneToOne private User user; @OneToOne private Game… Read More Is possible to have a Composite Primary Key which components are entity foreign keys?

"org.hibernate.PersistentObjectException: detached entity passed to persist" error that I can't work my head around

I’ve recently started working with JPA and Hibernate for a school project, and it basically stores continents, countries and cities in a database. When trying to use the persist method on an entity, I get the error mentioned in the title. Whichever threads I’ve visited tackle a lot more complex problems, and don’t really help… Read More "org.hibernate.PersistentObjectException: detached entity passed to persist" error that I can't work my head around

javax.persistence.EntityNotFoundException: Unable to find kg.library.spring.library_spring.entity.Author with id 10000001

I’m new to Spring and I’m probably making the dumbest mistake, but I can’t solve this problem for more than 2 hours. According to the video tutorial, I did Pagination, I did it exactly like his, but he did not have relationships between entities. I think the error is in a one-to-one relationship between Author… Read More javax.persistence.EntityNotFoundException: Unable to find kg.library.spring.library_spring.entity.Author with id 10000001

Update statement is no query?

How do I define the update statement in the orm.xml. I have it as a named-query and everything works, but my teacher said that an update statement isn’t a query. I have tried a native query, but that wasn’t working. ORM-Type: <?xml version="1.0" encoding="UTF-8"?> <entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"> Update Statement: <named-query name="updateTshirts"> <query>… Read More Update statement is no query?