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 410463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:53:27+00:00 2026-05-12T17:53:27+00:00

What I am going to describe is a bit of legacy code. So there

  • 0

What I am going to describe is a bit of legacy code. So there is a lot of stuff I cannot touch/change.

This pseudo-code runs well the in Jboss 4.0.3,

big_messy_sql = "select t1.f1 as somealias, t2.f2 as somehthingelse  from obj1 t1, obj2 t2 where crazy_conditions....";

Query query = entityManager.createNativeQuery(big_messy_sql);


List<Object> results = query.getResultList();

for (Object oRow : results) {
    Object[] r = (Object[]) oRow;
    // Do more crazy stuff

}

So , it works.

Now I am trying to upgrade the Jboss server to 5.1.0GA, which will use more up-to-date version of hibernate

15:39:02,089 INFO  [Version] Hibernate Annotations 3.4.0.GA
15:39:02,167 INFO  [Environment] Hibernate 3.3.2.GA
15:39:02,183 INFO  [Environment] hibernate.properties not found
15:39:02,198 INFO  [Environment] Bytecode provider name : javassist
15:39:02,198 INFO  [Environment] using JDK 1.4 java.sql.Timestamp handling
15:39:02,495 INFO  [Version] Hibernate Commons Annotations 3.1.0.GA
15:39:02,511 INFO  [Version] Hibernate EntityManager 3.4.0.GA

Then I got this exception:

12:06:09,031 INFO  [BigDecimalType] could not read column value from result set: id; S0022: Invalid column name 'id'.

I believe it is because this version of hibernate tried to map the result set into class obj1 and obj2 respectively. These java classes are retrieved from database via JPA properly elsewhere in this application (ie. we do have all the @Entity, @Table and @Column etc applied to the class obj1 and obj2.) Since the id columns is aliased to something else in this messy query, the ORM failed.

Here comes my question:

Is there anywhere I can disable the auto mapping of the Native Query?

I wanna avoid going the whole nine yards of defining a SQL mapping for this messy beast.

  • 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-12T17:53:27+00:00Added an answer on May 12, 2026 at 5:53 pm

    Instead of using SQL mapping, you can achieve this using createSQLQuery and addEntity. Check out http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querysql.html

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

Sidebar

Related Questions

This problem is a bit hard to convey with code so I'm going to
This one's going to be a bit of a challenge to describe. I have
I'm going to try and describe the code in my view, without actually posting
I'm going to describe what I'm trying to do generally (in case there's a
Please bear with me on this one. I am first going to describe an
I am going to describe my specific case below, but this might be useful
Im going to try to describe this the best way I can. The best
This is going to be a tough question to describe, but here goes. We
I'm going to design a RESTful API soon, thus I need to describe it
Obviously, Java doesn't support unsigned number types natively, and that's not going to change

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.