Skip to content
Advertisement

Tag: hibernate

org.hibernate.MappingException: collection foreign key mapping has wrong number of columns

I have a class Subject as such, Its composite Id is defined in SubjectId class as such, On compiling, I get the error org.hibernate.MappingException: collection foreign key mapping has wrong number of columns: com.example.Subject.students type: component[name,teacher] While this points the error to students element, the error occured after I removed the autogenerated id of Subject, and replaced it with combination

Transform SQL to Hibernate criteria

I am writing a method for retrieving clients with sum of their orders (order.total) higher and less than input values. All its okay, but, sometimes i am get an error: How can i correcting this method, or, maybe, convert this in full criteria style? Answer In the end, i solved this problem by this way, using sql restriction:

hibernate h2 embeddable list expected “identifier”

I’m trying to associate a list of function (whom Embeddable) within my Employee Entity and H2 seems unhappy with this saying that it expected an “identifier” Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement ” CREATE TABLE EMPLOYEE_FUNCTIONS ( EMPLOYEE_EMPLOYEEID VARCHAR(255) NOT NULL, ACTIVE BOOLEAN NOT NULL, DEPARTMENTNUMBER INTEGER NOT NULL, DESCRIPTION VARCHAR(255), ORDER[*] INTEGER NOT NULL ) “; expected

What version of JPA am I using?

I’m using in a apache-tomcat-8.0.41 web service. In this link they say “Hibernate EntityManager implements the programming interfaces and lifecycle rules as defined by the JPA 2.0 specification” https://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html_single/ But it’s for the 3.6 version. It’s the same for 5.1 ? Answer I suggest you read the docs of the version you are using. As for hibernate and JPA compatibility

@PreUpdate doesn’t save parent object when it’s updated

I have two entities with relation one to many. Parent can have several Child entity instances. I added a field to the parent that stores the date of children modifications(childrenLastModifiedDate). To maintain that, I added method: Here is the problem. It’s not always invoke when the child is saved. Locally(mac os), it works as expected, all three types of changes

“Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements”

Good morning Stackoverflow, I have the problem that it gives me the error: Failed to create sessionFactory object.org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: nl.scalda.pasimo.model.employeemanagement.EducationTeam.coachGroups Do you know why? Answer The Exception is straightforward and says : Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements, so the cause

Advertisement