i want define 2 @namednativequery on entity class . when tying define eclipse gives error.
duplicate annotation of non-repeatable type @namednativequery. annotation types marked @repeatable can used multiple times @ 1 target.
from error , know cannot define 2 define 2 @namednativequery of entity class like
@entity @table(name = "abc") @namednativequery(name = "abc.getsomemethod1" query = "some_query",resultsetmapping ="abcdto")//1st name query // @namednativequery(name = "some_name" query = "some_query",resultsetmapping ="some_dto")//try define second query , gives error public class abc { }
i using spring repository @ dao layer called method bind query
public interface someinterface extends jparepository<abc, long> { @query(nativequery =true) list<abcdto> getsomemethod1(@param("someparam1") long someparam1, @param("someparam2") string someparam2); }
the senario want run 1st native sql (which run fine) query , run 2nd native sql query(want run same). how solve or possible solution.
if way cannot run 2 native sql query there other achive this.
you can define multiple named queries this
@namednativequeries({ @namednativequery(name = "abc.getsomemethod1" query = "some_query",resultsetmapping ="abcdto" ), @namednativequery(name = "some_name" query = "some_query",resultsetmapping ="some_dto" ) })
then in business layer under transaction can call these 2 queries 1 after another,
if simple join between 2 entities , select , display better go join's. remember have columns index in table ;)
Comments
Post a Comment