0

I have reviewed the examples that are close to what I am trying to solve. But they use such odd or complex naming conventions I am cross eyed in reviewing and re-reviewing them. So I am trying here. I've looked for example at the following:

So the basics of my SQL Tables are: owner table - ID - owner_name ownerproperty table - ID - address - owner_id

So when the user logins I grab their "owner_name". I pass that to my Service but need to do a join/lookup for the owner ID as that is what is in the ownerproperty table(I didn't set this up). The point is I need to grab the user's properties from teh ownerproperty table as they could have many listed in there.

I am extending JpaRepository and in there I have custom query that begins with @Query("select id from owner where owner_name: myParam") MyCommunities findByOwnerId(@Param("myParam" String myParam);

I assuming that this means that "myParam" is the user's name that I get and pass through. ANd that is put in the @Query and the value returned is what is passed to findByOwnerId. From what I understand JPA/Spring/Hibernate does its magic and queries owernproperties table through the Entity I have set up as "owner" has a getter/setter in the Entity and it is a field in the table.

but I cannot compile as it flag the @Query line with "start of illegal type". I've tried researching this and cannot find what I'm doing wrong.

I have imported jpa.repository.Query, repository.query.Param, util.Optional, and repository.Repository.

STP
  • 51
  • 8
  • Include your JAVA entity classes pls. You have to use the property names, not the DB column names – Selindek Feb 28 '19 at 21:54
  • Update your question with Repository and with Full Details of Error or exceptions. Suppose your have feild called name in your entity then your naming convention should findByName() – Romil Patel Mar 01 '19 at 11:05
  • Actually the error went away when I realized that there are not two lines but one. I removed the semi colon after the @Query. – STP Mar 01 '19 at 14:08
  • But the real problem exposed itself. Angular JS is used ... a factory and restful web service. It works with Spring to either return all properites or just a specific one if an integer is appended to the rest uri. Im trying to figure out how to pass through a string which is the user's username and pull back just that user's properties. I have the username. I created a new factory in my Angular JS module/controller. I added it to my Spring controller etc. But no dice. . . so far. – STP Mar 01 '19 at 14:11

0 Answers0