Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6943087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:06:35+00:00 2026-05-27T13:06:35+00:00

select id,name,amount,sort from (select id,name,amount,sort,gift_id,count(gift_id) from (select * from t_lpw_gift g join t_lpw_dianxin_gift d

  • 0
select id,name,amount,sort 
from 
(select id,name,amount,sort,gift_id,count(gift_id) 
from 
(select * from t_lpw_gift g join t_lpw_dianxin_gift d on g.id=d.gift_id) 
group by gift_id,id,name,amount,sort order by count(gift_id) desc) 
where rownum <=5;

how to use jpa createNativeQuery to select,database is oracle

table:

SQL> desc t_lpw_gift;
Name   Type         Nullable Default Comments 
------ ------------ -------- ------- -------- 
ID     INTEGER                                
NAME   VARCHAR2(32)                           
PRICE  NUMBER                                 
AMOUNT INTEGER                                
SORT   VARCHAR2(32) Y                         

SQL> desc t_lpw_dianxin_gift;
Name        Type    Nullable Default Comments 
----------- ------- -------- ------- -------- 
GIFT_ID     INTEGER                           
DIANXIN_ID  INTEGER                           
GIFT_NUMBER INTEGER Y  

return Entity is t_lpw_gift

public List<Gift> getHotGifts(int topHotGiftsNum) {
    String sql = "select id,name,amount,sort from (select id,name,amount,sort,gift_id,count(gift_id) from (select * from t_lpw_gift g join t_lpw_dianxin_gift d on g.id=d.gift_id) group by gift_id,id,name,amount,sort order by count(gift_id) desc) where rownum <= :topHotGiftsNum";
return (List<Gift>)em.createNativeQuery(sql,Gift.class).setParameter("topHotGiftsNum", topHotGiftsNum).getResultList();
}

18:55:11,473 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 17006, SQLState: 99999
18:55:12,992 ERROR [org.hibernate.util.JDBCExceptionReporter] 列名无效()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:06:36+00:00Added an answer on May 27, 2026 at 1:06 pm

    On native SQL parameters in JPA, you need to use a positional parameter instead of a named parameter. Named parameters are not supported according to the spec.

    So, change :topHotGiftsNum to ?1, and setParameter(1, topHotGiftsNum).

    See this answer

    Edit: OK, that wasn’t it. This should be it: the select clause is missing some property from the entity, or one of the columns in the select clause is mis-typed. Your select clause needs to include all of the columns from the entity, without any difference in names. As per this thread from Hibernate forums.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I have this PHP code: $query = SELECT name, COUNT(message) FROM guestbook_message WHERE name='.$req_user_info['username'].'
I got this Doctrine query: select upper(substring(e.name, 1, 1)) first_letter from Application\Models\Exercise e group
SELECT name FROM sys.databases -- this can list all database name in the server
IF EXISTS (SELECT name FROM sysobjects WHERE name = 'myTrigger' AND type = 'TR')
Suppose I am calling a query SELECT name, city, country FROM People. Once I
Let's say I have SELECT name FROM table which gives me something like foo
I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0;
Why this query doesn’t working: SELECT name FROM ( SELECT name FROM table1 UNION
I want to use a query like: sql(select name where id > 10 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.