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

@NotNull annotation doesn't work as expected Edited

Hy Nguyen Oct 23, 2018

Hi,

I'm trying to create an Entity class named SchemeEntity with not-null name, so I put @NotNull annotation above of getName() method.





public interface GraphicLanguageSchemeEntity extends Entity {

    @NotNull
    String getName();

    void setName(String name);

    String getDescription();

    void setDescription(String description);

    @OneToMany(reverse = "getGraphicLanguageScheme")
    WorkflowEntity[] getWorkflowGraphicEntries();

    @OneToMany(reverse = "getGraphicLanguageScheme")
    GraphicLanguageEntryEntity[] getGraphicLanguageEntries();
}



This is the code that I used to insert new object to database:


 @Override
    public GraphicLanguageSchemeEntity createGraphicLanguageScheme(String name, String description) {
        writeLock.lock();
        try {
            GraphicLanguageSchemeEntity graphicLanguageScheme = ao.create(
                GraphicLanguageSchemeEntity.class);
            graphicLanguageScheme.setName(name);
            graphicLanguageScheme.setDescription(description);
            graphicLanguageScheme.save();
            return graphicLanguageScheme;
        } finally {
            writeLock.unlock();
        }
 }



As I expected, when I insert a new SchemeEntity into database, as long as it has some "name", the creating should be success.

 

But some how when I executed the code, with not-null value for name, I got the error message:


Exception: class java.lang.IllegalArgumentException The follow required fields were not set when trying to create entity 'com.mgmtp.jira.plugin.workflowgraphic.dao.entity.GraphicLanguageSchemeEntity', those fields are: ImmutableFieldInfo{fieldName='NAME', polymorphicName='null', accessor=public abstract java.lang.String com.mgmtp.jira.plugin.workflowgraphic.dao.entity.GraphicLanguageSchemeEntity.getName(), mutator=public abstract void com.mgmtp.jira.plugin.workflowgraphic.dao.entity.GraphicLanguageSchemeEntity.setName(java.lang.String), primary=false, nullable=false, autoIncrement=false, defaultValue=false, fieldType=class java.lang.String, typeInfo=String:VARCHAR, generatorType=null}

 

The error occurred in this line:

    GraphicLanguageSchemeEntity graphicLanguageScheme = ao.create(
        GraphicLanguageSchemeEntity.class);


Did I do some thing wrong in my code, or this is a SDK's bug?

0 answers

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

1,274 views 2 13
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