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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:15:51+00:00 2026-06-02T13:15:51+00:00

I have a BUSINESS table that looks like this: BUSINESS_ID | BRN | CODE

  • 0

I have a BUSINESS table that looks like this:

BUSINESS_ID | BRN | CODE | PARENT_ID

A Business can have a parentBusiness, which is joined from child.parent_id->parent.brn and child.code->parent.code and can be represented by the query:

select * from business childbus left join business parentbus on childbus.parent_id=parentbus.brn and childbus.yppa_code=parentbus.yppa_code where childbus.business_id=?

How can I create that many-to-one relationship for business.parentBusiness? The following many-to-one mapping creates the link from PARENT_ID to BRN but how do I get the constraint from the CODE column in there?

<many-to-one name="parentBusiness" class="Business" column="PARENT_ID" property-ref="brn"/>

EDIT

It was suggested in an answer below that I try to use a formula. According to the docs the formula needs to return just the PK for the object and it will figure out how to populate itself. Here is where I’m at:

<many-to-one name="parentBusiness">
    <formula>(select parentBusiness.business_id from business parentBusiness where parentBusiness.brn=parent_id and parentBusiness.code=code)</formula>
</many-to-one>

But this creates an sql error

...
from Business business0_
left outer join Business business1_ on
    (select parentBusiness.business_id from business parentBusiness where parentBusiness.brn=business0_.parent_id and parentBusiness.code=business0_.code)=business1_.BUSINESS_ID

because, of course

ORA-01799: a column may not be outer-joined to a subquery

How should my formula be set up?

Many thanks in advance.

  • 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-02T13:15:52+00:00Added an answer on June 2, 2026 at 1:15 pm

    I was never able to get this complex relationship working as stated in the original question. I was, however, able to convince management that this was a poor data model.

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

Sidebar

Related Questions

I have a table that looks like this: Id (PK, int, not null) ReviewedBy
I have a view that will look like this: I'm trying to figure out
I have a table closures that consists of times when my client's business is
In our case we have some business logic that looks into several tables in
I have a business object that compiles into a DLL that handles all calculations
I have a business object project, which contains composite structure: public class Tree {
I have a business class which I need to serialize to xml. It has
We have a business case that would be perfect for multiple BackgroundWorkers. As an
I have a Business Layer that passes a Conn string and a SQLCommand to
I have a Notes table with a uniqueidentifier column that I use as a

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.