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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:17:12+00:00 2026-06-11T10:17:12+00:00

I have a table that uses a surrogate primary key. The natural key of

  • 0

I have a table that uses a surrogate primary key. The natural key of the entity (table) is namespace + name. The web application accessing the table will offer the user a web form that allows the user to update any property of the entity. I am using Hibernate for ORM. When issuing a session.update(entity), the entity would need to have its ID (surrogate key) populated to allow Hibernate to identify the record in the database. I can think of 2 ways of doing this

(1) pass the ID (hidden) to the front-end and then back to the business layer upon update on the form

(2) pass only the natural keys and do a lookup using natural keys in the DAO layer to get the ID.

Note that the natural keys cannot be updated using the form. There is a separate form for altering the identity (namespace + name) of the object and concurrency isn’t an issue i.e. no one would be able to alter the identity while someone else holds a lock for update so looking up using the natural key would still yield the same record that was used while requesting the update.

Questions

(1)Are there any approaches besides the ones I have mentioned?

(2)How is this typically accomplished in web applications?

I tried searching but couldn’t find much information on this; probably not searching with the correct choice of words.

  • 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-06-11T10:17:13+00:00Added an answer on June 11, 2026 at 10:17 am

    Both approaches are valid and I don’t even know what to say more. It’s up to you how to implement this, though if you’re using surrogate key and 2nd level cache is activated, then entity might be taken from the cache directly which will increase the performance if those operations are often used. Searching by natural key will bypass the cache.

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

Sidebar

Related Questions

I have a web page that uses jquery ajax to grab the table markup
I have content management system application that uses a polymorphic tree table as the
I have an application that works with a database that uses foreign key constraints.
I have an entity/table that uses sqlgeography. Since EF 4.X doesn't support spatial types
I have an Android application that uses the Android database to create tables and
I have a table column that uses an enum type. I wish to update
i have a table in sql that uses the adjacency model to create child/parent
following on from my other post... I have a table that uses two fields
I have a DB table that uses the following schema: CREATE TABLE users (id
I created a web app that uses a MySQL database, but I have to

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.