• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

org.hibernate.PropertyNotFoundException: Could not locate setter method for property

 
Ranch Hand
Posts: 1021
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi experts,

I have been trying to fix the above Spring Boot JPA error for the whole day without avail.




I have edited the Enum in the entity Pet to as follows and make sure it has setter but still I am getting the error :



I am absolutely upset till now I can't still nail the problem and would appreciate some helps from the experts here.

Is there a simpler way to make my JPA project just create the table without all these issues ?


Tks.

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your getter and setter don't match. The getter is called getStatus, but the setter is called setPetStatus. Either use getPetStatus and setPetStatus, or getStatus and setStatus, but don't mix them.
 
tangara goh
Ranch Hand
Posts: 1021
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Your getter and setter don't match. The getter is called getStatus, but the setter is called setPetStatus. Either use getPetStatus and setPetStatus, or getStatus and setStatus, but don't mix them.



Thanks to you.  If not for you, I think until tomorrow I will still be stuck.

How do I stop myself from getting overly panic ?  I mean I always wasted time going round in circles but can't fix the issue.
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Your getter and setter don't match. The getter is called getStatus, but the setter is called setPetStatus. Either use getPetStatus and setPetStatus, or getStatus and setStatus, but don't mix them.



Actually, since the property value itself is named petStatus, the "getter" method should be named getPetStatus.

Also, since this is a JPA Entity class, you need a no-argument constructor and overrides for the hashCode() and equals() methods.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Also, since this is a JPA Entity class, you need a no-argument constructor


Yes, but that's there already - the default constructor.

and overrides for the hashCode() and equals() methods.


Those aren't necessary, and I hardly ever write them. JPA doesn't need it for equality in many-to-many or one-to-many collections, it uses the id for that. That means there is need for an @Id column. I assumed it was omitted for brevity.

hashCode and equals are only needed for @Embeddable classes that are used as compound key. For the rest JPA really doesn't care.

 
Tim Holloway
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think JPA requires a primary key (ID) on entities, especially since SQL itself doesn't. So the @ID wouldn't always work. The equals method is overridden to determine the absolute identity of a record so that if you have 2 instances - especially detached instances - you can tell if one is a modification/update of the other or if they are in fact 2 different rows in the table.

hashCode, of course, must track equals(), so when minor fields in the entity change, the hash won't change. The hashCode has been used since JPA v1 as a means of locating cached copies of entities.
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic