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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:44:36+00:00 2026-06-07T03:44:36+00:00

Imagine a City to Postalcode relation mapping. (For simplicity using no foreign-keys) <class name=CityToPostalcode

  • 0

Imagine a City to Postalcode relation mapping. (For simplicity using no foreign-keys)

<class name="CityToPostalcode" table="city_to_postalcode" catalog="database">
    <id name="id" type="java.lang.Integer">
        <column name="id" />
        <generator class="identity" />
    </id>
    <property name="city" type="String">
        <column name="city" not-null="true"/>
    </property>
    <property name="postalcode" type="Integer">
        <column name="postalcode" not-null="true"/>
    </property>
    <properties name="businessKey" unique="true">
        <property name="city"/>
        <property name="postalcode"/>
    </properties>
</class>

Is there a function in the framework to check if the unique key “businessKey” for a given combination is unique (also for single-column unique constraints)?

Maybe in combination of mapping “businessKey” to a class? (Similar to usage of composite-id)

It is just so much redundance to write the code for each table to check its business-key, if it definetly could be done automatic.

  • 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-07T03:44:38+00:00Added an answer on June 7, 2026 at 3:44 am

    there is natural Id which automaticly creates a unique constraint on schema creation and can be used to query for it more efficiently. in xml

    <natural-id>
        <property name="name"/>
        <property name="org"/>
    </natural-id>
    

    naturalids use the second level cache more efficient and from H4.1 on loading by naturalid uses the first level cache and can save roundtrips. Other than that natural ids are just like normal properties. you could however write a generic natural id checker

    1. create a new object with the properties set
    2. access through the sessionfactory the classmetadata of the object
    3. iterate the natural id properties and use them to get the values from your object and set them on the using(propertyname, propertyvalue)
    4. if something is found copy the data, else just save the object you just created
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi there imagine I have a table like this Id | Name | City
Imagine I have following table: NAME DATE OTHER_CONTANT 'A' '2012-06-05' 'baz' 'A' '2012-06-04' 'bar'
Imagine I have this simple table: Table Name: Table1 Columns: Col1 NUMBER (Primary Key)
imagine this html on a page <div id=hpl_content_wrap> <p class=foobar>this is one word and
Imagine you have class A which has code which runs as method M. And
I'm designing a city building game and got into a problem. Imagine Sierra's Caesar
Imagine there is a jar (named lib.jar ) that contains a single class and
Imagine this: Class A{ private int a; } Class B{ public void fn(){ A
Imagine a table for articles. In addition to the main query: SELECT * From
Imagine a xml file like this: <Document> <Tests> <Test> <Name>A</Name> <SubTest> <Test> <Name>B</Name> <Value>100</Value>

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.