AO - neat way for multiple OneToOne type references in a type

@OneToOne allows mapping of Types in AO, but how AO maps these is done from the direction of WindowType, (i.e. setX on WindowType), and will work fine, for exactly one method, but not so much for mulitple methods, to illustrate the point, the following Entity X will not be able to return different values due to lack of a discriminator:

interface X extends Entity { 
@OneToOne WindowTypeXref getTheSquareWindow(); 
@OneToOne WindowTypeXref getTheRoundWindow(); 
@OneToOne WindowTypeXref getTheOvalWindow();
}

interface WindowTypeXref extends Entity { 
public X getX(); 
public void setX(X anX); 
public void setWindowType(WindowType t); 
public WindowType getWindowType(); 
}

Ideally I'd like to be able to add a where clause to @OneToOne, eg (@Discriminator="SOMECOL='oval'"). With that future feature out there, I'm currently left with:

1) storing the KEY to the XREF in X (I'd do this to be able to have a many to one reference from Xref to WindowType)

2) having multiple tables, one per 'method' in X (Id rather not increase in table cruft)

Is there a neater solution?

2 answers

1 accepted

1 vote

Hey Andy,

I think I found a way that would satisfy you, but there seem to be some caching issue preventing this from working as expected, see https://studio.atlassian.com/browse/AO-313

0 vote

Why don't you define your entities like so?

interface X extends Entity
{ 
    WindowTypeXref getTheSquareWindow();
    void setTheSquareWindow(WindowTypeXref w);
 
    WindowTypeXref getTheRoundWindow();
    void setTheRoundWindow(WindowTypeXref w);

    WindowTypeXref getTheOvalWindow();
    void setTheOvalWindow(WindowTypeXref w);
}

interface WindowTypeXref extends Entity
{ 
    @OneToOne public X getX(); 

    void setWindowType(WindowType t); 
    WindowType getWindowType(); 
}

Isn't that achieving the same, or am I missing something?

Hi Sam, let me restate, perhaps I gave a bad example. Putting into terms I can relate to today, so I have a [Config] which can be many, I have [TemplateSets] which can be many, but each TemplateSet has a type identifier (window analogy). Wahat I wanted to do was have mulitple methods in [Config] retrieving a specific [TemplateSet] through an Xref, which is why @onetoone didnt work, as "there can be only one" reference per table?

In any case, for now, I resorted to breaking referential integrity and just storing the ID of the [TemplateSet] three times, in the [Config], which works fine, with surrounding logic to protect deletion etc. It also allow relatively simple determination from [TemplateSet] waht [Config] refer to it.

Yup, looks to be what I would like, but as you say, caching may be a problem, I'm watching for future comment, thanks!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

439 views 6 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you