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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:24:41+00:00 2026-05-26T08:24:41+00:00

Example: @Entity class Table_A{ @Id @generatedValue private long ID; @Column private String name; @Transient

  • 0

Example:

@Entity
class Table_A{
    @Id
    @generatedValue
    private long ID;

    @Column
    private String name;

    @Transient
    private String otherName;

    // getters and setters

    public long getID()
    { return ID;}
    public void setID(long ID)
    { this.ID = ID;}

     public String getName()
    { return Name;}
    public void setName(String name)
    { this.name = name;}

    public String getOtherName()
    { return otherName;}
    public void setOtherName(String otherName)
    { this.otherName = otherName;}
}

Query Example:

String sql = "SELECT Table_A.*, otherName 
FROM Table_A INNER JOIN Other_Table ON Table_A.id = Other_Table.id";

List<Table_A> = em.createNativeQuery(sql, Table_A.class).getResultList();

NOTE:

“otherName” column is a field of Other_Table.

Other_Table is not an Entity

PROBLEM:

the problem is, I can’t store the “otherName” column result to the @Transient field of the Table_A entity. Is there any way of doing this? It always returns null.

  • 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-26T08:24:41+00:00Added an answer on May 26, 2026 at 8:24 am

    The problem is that you’ve used the form of createNativeQuery that expects to be able to place the result directly into your class Table_A – but of course the otherName won’t map.

    If you use the other form of createNativeQuery, that uses a named @SqlResultSetMapping, you might be able to get the value of otherName into a @ColumnResult that you can use. Have a look at the example here.

    I’m afraid you’ll still probably have to manually call setOtherName() at some point though 🙁

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

Sidebar

Related Questions

A have two entities. For example timing settings and orders. @Entity public class TimingSettings{
I have this Entity called 'Operation': @Entity @Table(name=operation) public class Operation implements Serializable {
i've got following example xml: <entity id=1> <name>computer</name> <type>category</type> <entities> <entity id=2> <name>mac</name> <type>category</type>
i have the two classes Person and Attribut, in short: @Entity @Indexed @Table(name=persons) public
I've 2 tables with same column's name, for example, both table A and table
Taking the following object model: public abstract class Entity { public Guid Id {
Consider the following example: public interface Bar { } @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public
Why is twitter double encoding XML entity references? Here's an example tweet: xml entity
I would like to POST an entity as follows POST /example.org/MyEntity/100 Based on the
In this example, the Google App Engine documentation makes the Customer the entity group

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.