Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Active Objects - Composite Primary Key

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2015

How to configure composite primary key on an entity?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Arthur
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2016

in AO Version 1.2.0 there is support for composite indexes:

https://developer.atlassian.com/docs/atlassian-platform-common-components/active-objects/ao-1-2-0-upgrade-guide

 

import net.java.ao.Entity;
import net.java.ao.schema.Index;
import net.java.ao.schema.Indexes;
 
@Indexes({
    @Index(name = "names", methodNames = {"getFirstName", "getLastName"}),
    @Index(name = "age", methodNames = "getAge")
})
public interface Person extends Entity {
    public String getFirstName();
    public void setFirstName(String firstName);
    public void setLastName(String lastName);
    public String getLastName();
    public int getAge();
    public void setAge(int age);
}
Asif Diwan October 24, 2018

Hi Arthur,

I tried using creating the same entity mentioned above in my plugin. AO version 1.2.0

But still table was created without indexes. 

There were no indexes created in DB. Let me if I am making a mistake or missing any step.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 28, 2015

I think you need to explain that in a lot more detail.  The last kitchen designer I spoke to said almost the same thing and that has nothing to do with JIRA

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2015

AO auto assigns ID field as primary key but I want to set 3 columns as primary key on the table.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 29, 2015

You can't do that, the ID is a unique identifier handled by JIRA and the AO code, it needs it to be of a certain format. If you really desperately need to do it, you'd need to change core code in JIRA's AO implementation to support it.

Alexej Geldt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2016

If that is true, then AO is not a relational database interface, since composite primary keys is one of a key features of relational databases. You can find composite keys in almost any software which is persisting data to a database. Imagine if you wanted to migrate such software to use active objects without support of composite keys. You would have to rewrite your entire model and business logic too. There must be a way to do that in AO. All kinds of databases that i heard of are supporting composite keys. This is true even for the in-memory-database hsql which is used by JIRA by default.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 25, 2016

You're confusing database with datastore.  JIRA uses databases as datastores (and takes advantage of some low-level features like indexing).  It does not pretend to use it as a relational database.  It's for storing data.

Alexej Geldt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2016

Nic Brough [Adaptavist]

in the active objects bundle for some reason an annotation @PrimaryKey exists.

Its Javadoc is saying:

Marks a method such that the corresponding database field will be the primary key for the table in question. Using this annotation, it is possible to specify arbitrary primary key field names and types.

The logic in both migrations and entity invocation handling assumes that there is only a single primary key per entity type. If the entity type does not contain exactly one field (may be more than one method) as a primary key, odd errors will ensue.

Quite unclear.

On one hand it is saying that this annotation is used to define primary key field names and types, suggesting that multiple fields are possible.

On the other hand it is saying that AO is assuming that there is only a single primary key per entity type. And that odd errors will ensue if there is more then one.

 

Sounds like the devs of AO didn't see the need of composite primary keys and din't realy know whats going to happen and why its going to happen when you use their PrimaryKey annotation on multiple methods of same entity.

 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 25, 2016

Yes, I understand that, but you're missing the point again.  It's not a relational database.

Alexej Geldt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2016

It doesn't matter if it is a relational database.I just said, that if there is no support for composite keys in AO, you cannot call it like so.

The lack of support for composite primary keys just leaves you without many options when designing persistence model for your plugins.

 

 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 26, 2016

I'm not sure what you're asking now. 

Alexej Geldt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 28, 2016

nothing, just commenting your anwser.

TAGS
AUG Leaders

Atlassian Community Events