Categories: java, spring, jpa

Spring JPA Costum Return Type with Join

1 answer
 public class UserTransfer{     private String u_email;     private String u_password;      public UserTransfer(String u_email,String u_password) {         this.u_email=u_email;         this.u_password=u_password;     }      public String getU_email() {         return u_email;     }      public void setU_email(String u_email) {         this.u_email = u_email;     }      public String getU_password() {         return u_password;     }      public void setU_password(String u_password) {         this.u_password = u_password;     } } 
@Repository public interface UserTransRepositiory extends JpaRepository<UserTransfer, String>  {      @Query(value ="SELECT " + "new paddelec.backend.model.UserTransfer(u.u_email,u.u_password)"             +" FROM tokens t JOIN users u ON t.u_email=u.u_email WHERE t.token= ?1")     UserTransfer findByToken(String Token); }  

This is my Code I try to generate a UserTranfer Object. The regular TokenTransfer and User Repository works just fine. But here I am getting the "java.lang.IllegalArgumentException: Not a managed type: *.UserTransfer" Exception.

All answers to this question, which has the identifier 61224255

The best answer:

UserTransfer must be a JPA entity -> annotate the class with @Entity

->

@Entity public class UserTransfer{     private String u_email;     private String u_password; 

Moreover don't forget that each entity must have an @Id . Example : if the u_email is the primary key , annotate it with @Id

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data