I have an Entity class for Item, but what I want to do is have it so that people can look up a keyword and find the item instead of having to type the exact name. For example, if you have popsicle sticks as an item, I want them to be able to just type popsicle and get the item back.
Here is my repository class.
I'm getting an error that Keyword is not a property of item.
However, I made another program similar to this, and it worked just fine, so I don't understand the error and how to fix it.
When I change it to findItemByName, it only gives back the results if I type the exact name of the item and ignores the custom query.
Well, you shouldn't use native queries at all unless there's a compelling reason not to use JPQL.
But I suspect that your fault was that you coded "where i.name LIKE %:keyword%" when you should have coded "where i.name LIKE '%:keyword%'". Note the extra quotes because this is now a string expression and not a direct variable reference.
Although if I remember correctly. there are some problems with that sort of syntax, so I'm glad you found a solution.
Some people, when well-known sources tell them that fire will burn them, don't put their hands in the fire.
Some people, being skeptical, will put their hands in the fire, get burned, and learn not to put their hands in the fire.
And some people, believing that they know better than well-known sources, will claim it's a lie, put their hands in the fire, and continue to scream it's a lie even as their hands burn down to charred stumps.
You can thank my dental hygienist for my untimely aliveness. So tiny:
SKIP - a book about connecting industrious people with elderly land owners