Issue regarding spring jpa framework

Hi,

I use a spring Jpa framework...
I have a query which get  inserted into  a table,  my question is which  spring jpa query builder i should use  to support this kind of queries..

Thanks
Roy...


insert into @table
select
bt.panelTestCode,
convert(varchar,cc.cptCode) + ' x' + convert(varchar,count(1)) + ', ' as [text()]
from tblTestMenu tm (NOLOCK)
left join tblTestRequisition tr (NOLOCK) on tm.testMenuId = tr.testMenuId
left join tblRequisitionType rt (NOLOCK) on tr.reqTypeId = rt.reqTypeId
left join tblBillingTest bt (NOLOCK) on bt.testMenuId = tm.testMenuId
left join tblBillingComponent bc (NOLOCK) on bc.billingTestId = bt.billingTestId
left join tblTestComponent tc (NOLOCK) on tc.componentId = bc.componentId
left join tblCPTPrice cp (NOLOCK) on tc.cptPriceId = cp.cptPriceId
left join tblCPTCode cc (NOLOCK) on cc.cptCodeId = cp.cptCodeId
where panelTestCode is not null
group by bt.panelTestCode, cc.cptCode
order by 1,2
roy_sanudeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

roy_sanudeveloperAuthor Commented:
i was going some of the stuff  like @query or @namedQuery or @nativequery for the above query framework ....Getting confused which builder i should use.. can some body clarify it...

Thanks
gurpsbassiCommented:
I think for something like this I would use the entity manager directly to execute the insert:

entityManager.createNativeQuery(sqlStatement).executeUpdate();
entityManager..getTransaction().commit();
Jim CakalicSenior Developer/ArchitectCommented:
If you're annotating your entity class then use @NamedQuery when writing JPQL and use @NamedNativeQuery when writing SQL. The @Query annotation is from Spring Data and it's used on Spring JPARepository interfaces and can be used for both JPQL and SQL but it is not a JPA defined annotation.

Jim

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.