• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Composite Key causing error in Entity Class- AnnotationException

 
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to create an application which schools can use for Prom to assign a ticket to a student and enter the ticket number in the website to grant access.  

Since a student ID can be the same at different schools, I created a composite key for the student ID and school ID in mySQL.

Here is the student class.  Getters and Setters omitted.



So, I created a student identity class to map the school ID and student ID together, but since School also has its own entity class, I'm not sure I did it right.  




I'm getting an error.    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unable to find properties (studentId, school) in entity annotated with @IdClass:com.kenmilota.promticket.entity.Student
 
Ranch Hand
Posts: 174
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error is right in front of you:
```Unable to find properties (studentId, school) in entity annotated with @IdClass:com.kenmilota.promticket.entity.Student```
 
Nathan Milota
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But it is there though.   It is in the StudentIdentity class.  
 
Salil Wadnerkar
Ranch Hand
Posts: 174
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
`EmbeddedId` talks about what is the composite key for this record. It is not going to add properties of `StudentIdentity` as properties of `Student`
 
Nathan Milota
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I added the studentID and School, it still didn't work.
 
Nathan Milota
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nearly all the videos I've watched and websites I've looked at with examples did it this way, and it works just fine.   I don't get what I'm doing wrong.
 
Nathan Milota
Ranch Hand
Posts: 447
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think there is a bug in the IDE or something.   I'm doing it right.
 
Marshal
Posts: 27534
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start at the beginning by downloading a project from one of those tutorials you saw on line. Install it into your IDE unchanged and see what happens.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it is still relevant, try to remove @IdClass(StudentIdentity.class) annoation from your Student class.

IdClass and EmbeddedId are similar but not the same.

IF your intention is to use @EmbeddedId (as I see it is), @IdCass annotation is not needed at all and this is the one causing your error.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic