It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Active Objects with @Unique constraint in entity fields Edited

I am trying to add 'Unique' constraint to my entity column name. 

Example code here:

public interface TestEntity extends Entity {

@PrimaryKey(value = "ID")
int getID();

String getUserKey();

void setUserKey(String user_key);


Whenever I try to use this in My DAO layer 


TestEntity userEntity = activeObjects.create(TestEntity.class);



It gives me SQL exception on the first line that 

user_key cannot be null. It tries to insert an entry before even I set the value and call save. If I remove @unique tag it works fine. But then how to enforce unique constraint on the column. Is there any other way that I am missing here that can solve my purpose or do I need to call a get first to see if name is unique. Your input is well appreciated. Thanks


0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Introducing new features for Jira Software Cloud's roadmap

Hi Atlassian community, A few months ago, we offered a sneak peak of the new hierarchy view on the roadmap. Thank you for all the feedback (and excitement) and for helping us shape the direction of...

24,929 views 116 85
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you