java - How to populate non-entity POJO class by executing dynamic query using Spring and Hibernate -


i'v got task migrate part of project ibatis hibernate. have following tables:

create table manufacturer (   country varchar(3)   not null,   code    varchar(2)   not null,   name    varchar(100) not null,   primary key (country, code) );  create table model (   country           varchar(3)   not null,   manufacturer_code varchar(2)   not null,   code              varchar(2)   not null,   name              varchar(100) not null,   primary key (country, manufacturer_code, code),   constraint fk__model_manufacturer foreign key (country, manufacturer_code) references manufacturer (country, code)   on delete cascade   on update cascade ); 

i created entity classes , repositories manufacturer , model. works far. need implement dynamic query (ibatis mapper @select):

select country, code, name, <if test="criteria.text != null">,array_to_json(regexp_matches(name, #{criteria.text},'i')) match</if> manufacturer upper(country) = upper(#{countrycode}) <if test="criteria.text != null"> , name ~* #{criteria.text}</if> order name </script> 

it's used searching manufacturer name regular expression. result contains manufacturer code , name , details regexp matches. result stored within non-entity pojo class through ibatis result map.

could please advise how achieve using jpa? or recommend way how achive this? how resolve such task? please elaborate bit more in detail, i'm learning novice on field. many in advance.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -