java - How to provide values from a class which is not an entity to a repository in spring data -


i have doubt spring data , spring repositories. need provide values crudrepository class not entity. example: have class

@entity class profile {    private string id;    private string name;    private long birthdate;    private string aboutme;    ... } 

and

class myprofile {    private string profileid;    private string accountid;    private string name;    private string aboutme; } 

and repository

@transactional @enabletransactionmanagement @repository public interface profilerepository extends crudrepository<profile, string>{      @transactional     profile findbyaccountid(string id);      void updatemyprofile(myprofile myprofile); } 

and update fields profile using data provided in myprofile. there way this?

thanks!!

you have write update query manually:

@query("update profile p" +         " set " +         " p.name = ?#{#myprofile.name}, " +         " p.aboutme = ?#{#myprofile.aboutme}" +         " p.account.id = ?#{#myprofile.accountid}" + // assume account entity         " p.id = ?#{#myprofile.profileid}") @transactional @modifying void updatemyprofile(@param("myprofile") myprofile myprofile); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -