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

  • Home
  • SEARCH
  • 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 337275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:19:14+00:00 2026-05-12T10:19:14+00:00

I have a database that can have different types of relatinships based upon what

  • 0

I have a database that can have different types of relatinships based upon what data was updated during the last business transaction. An example would be in a policy writing application. The main table contains generic policy level information and there are related tables containing information such as the agent’s information and the insureds information. When the first transaction is issued all of the tables are populated, however on subsequent transactions only the tables that have updates are persisted to the database. What I am trying to do now is to create classes implementing JPA that define the relationships between the tables as one-to-one. I would then like to implement custom loaders for each of the relationships to ensure that each time I retrieve the policy entity I can be able to retrieve the most recent version of the corresponding tables. Does anyone know how to implement this logic? I have tried using @NamedNativeQuery and using HQL, but in both instances it tells me that a column name I am specifying doesn’t exist.

Any assistance would be greatly appreciated.

Code has been provided below to help illustrate what I am doing.

@Entity
@NamedNativeQuery(name = "loadLatestBilling",
                  query = "Select {i.*} from TransactionSummary as ts outer join BillingInfo i on i.systemAssignId=ts.systemAssignId where ts.systemAssignId=:systemAssignId and i.transSeqNo<=:transSeqNo order by i.systemAssignId, i.transSeqNo DESC",
                  resultClass = BillingInfo.class)

public class CoTransactionSummary implements java.io.Serializable,
    CdbCoTransactionSummary {


@OneToOne(targetEntity = BillingInfo.class, fetch = FetchType.LAZY)
@org.hibernate.annotations.NotFound(action = org.hibernate.annotations.NotFoundAction.IGNORE)
@Loader(namedQuery = "loadLatestBilling")
public BillingInfo getBillingInfo() {
    return billingInfo;
}

public void setBillingInfo(BillingInfo billingInfo) {
    this.billingInfo= billingInfo;
}

}

In the above example the SystemAssignId would be common between all of the records pertaining to that entity. The transSeqNo would be incremented for each successive transaction and thus the custom loader would look for the highest value associated with the systemAssignId.

Thank you very much for any assistance that you can provide.

  • 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-12T10:19:14+00:00Added an answer on May 12, 2026 at 10:19 am

    Your named query is wrong – you can’t have named parameters in it. You can only have one positional parameter which will be replaced by primary key value (well, there may have to be more than one for composite ids but that doesn’t apply in your case). I also don’t think it’s legal to return more than one value from it; though Hibernate may let it slide.

    Now, since the query has to be based off PK (BillingInfo PK) it will not be easy to do what you want via one-to-one mapping (unless, of course, you intend to actually update your CoTransactionSummary every time to point to an appropriate BillingInfo; but in that case you don’t need all that custom loading stuff). You’ll basically need to rewrite your query to join to BillingInfo table twice – first time to get TransactionSummary PK of BililngInfo record with PK supplied by Hibernate and second time to get the latest BillingInfo record. The whole thing seems rather messy.

    Consider using one-to-many mapping instead (you can always make BillingInfo collection private and only expose the appropriate instance via public getBillingInfo() method).

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

Sidebar

Related Questions

I am creating a database of structures that can be of different types. Each
I am setting up a database that represents different types of content. I have
I have a few different types of companies that can access my web application
So we have a database column that can contain just about anything. Unicode, numbers,
I have to look into solutions for providing a MySQL database that can handle
I have a database that uses codes. Each code can be anywhere from two
If i have items stored in a database that users can download after they
Anyone have a PL-SQL statement that i can use to generate database & tables
I have a database of meetings. I can generate a report that sorts the
I have a form that shows results from a database query, these results can

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.