• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Composite Key causing error in Entity Class- AnnotationException

 
Ranch Hand
Posts: 416
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: 158
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: 416
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: 158
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: 416
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: 416
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: 416
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: 26381
81
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.
 
Why is the word "abbreviation" so long? And this ad is so short?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic