join more than one table in spring jparepository -


i trying fetch record doing join. new spring jparepository. understand there separate repository each entity(table) when implement need define entity , datatype of primary key.

could please suggest how can fetch record joining 2 tables.

i have 2 repo below:

public interface aentityrepository extends jparepository<aentity, integer>  public interface bentityrepository extends jparepository<bentity, integer> 

i want join above 2 entity(aentity, bentity). know can have custom query using below:

@query("select ****** aentity ae") aentity findcustomrrecords(); 

however can write same kind of query (join query) join. need have separate repository implementing other class.

can please help.

i using mysql.

i understand there separate repository each entity(table)

this common misunderstanding. not want have repository per entity, per aggregate root. see http://static.olivergierke.de/lectures/ddd-and-spring/

regarding specific problem @ hand: creating custom method in repository interface , annotating jpql should trick. like:

@query("select bentity b join b.a b.foo = :foo") aentity getallfooishas(string foo); 

you can use join syntax jpql offers in query.


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -