5

I have forked an Atlassian Stash plugin for build server integration, and it uses the ActiveObjects component for storing the data. I'm having the following issue:

If I follow the other fields and add a getter and setter for my OneToMany fields like this

@OneToMany
TestMapping[] getTestMapping();
void setTestMapping(TestMapping[] powerMappings);

When using the entity I get the following exception:

[INFO] [talledLocalContainer] Caused by: java.lang.RuntimeException: Unrecognized type: [Lsome.package.TestMapping;
[INFO] [talledLocalContainer]   at net.java.ao.types.TypeManager.getType(TypeManager.java:68) ~[na:na]
[INFO] [talledLocalContainer]   at net.java.ao.schema.SchemaGenerator.getSQLTypeFromMethod(SchemaGenerator.java:481) ~[na:na]

Googling for the issue only found the solution to remove the setter like suggested in this post. However, that takes away the possibility to set the field if a configuration already exists. I don't think deleting an ActiveObject and saving a new one is the way to go here.

How to fix this issue? Or if it is not possible, how to update an existing object without using setters in ActiveObjects?

TylerH
  • 20,799
  • 66
  • 75
  • 101
wonderb0lt
  • 2,035
  • 1
  • 23
  • 37

1 Answers1

2

The approach that I am following with Active Objects is like this. When you have some entity, A, which has many of another entity, B, and each B object has only one of A, I add these snippets:

In class A:

...

@OneToMany
B[] getBs();

...

And in class B:

...

A getA();
void setA(A a);

...

Note that there isn't any annotation at the methods added in the class B and that there isn't any added setter method on class A, the one which is at the "one" side of the "one-to-many" relationship. This approach always works for me. If you add a method that is not here, you add an annotation that I am not using here, or you miss to place the @OneToMany in the right place, then you usually end up with an unrecognized type exception.

I know it is really frustrating, as that exception only lets you know that your entity interfaces are not well constructed, but it doesn't let you know what is the problem or where it is. Try to copy exactly my approach.

TylerH
  • 20,799
  • 66
  • 75
  • 101
user3289695
  • 740
  • 1
  • 9
  • 20