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 '<hidden-package>.GraphicLanguageSchemeEntity', those fields are: ImmutableFieldInfo{fieldName='NAME', polymorphicName='null', accessor=public abstract java.lang.String <hidden-package>.GraphicLanguageSchemeEntity.getName(), mutator=public abstract void <hidden-package>.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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found the solution here: https://developer.atlassian.com/server/framework/atlassian-sdk/creating-entities/#creating-an-entity-with--not-null--constraints
To create a Application entity, I use this constructor:
final Application application = ao.create(
Application.class,
new DBParam("NOM",nomApplication),
new DBParam("NO_APPLICATION",noApplication),
new DBParam("UUID",uuid),
new DBParam("NOM_ABREGE",nomAbrege)
);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.