ActiveObjects SQL exception for column name when using AO plugin, but not TestActiveObjects

I implemented AO in my plugin and the IT tests (using TestActiveObjects and JUnitActiveObjectRunner) all pass to create, persist, update and find my objects.

But when I fire up my SDK instance of confluence the first query bombs out with

java.lang.reflect.UndeclaredThrowableException
at $Proxy1297.prepareStatement(Unknown Source)

caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: ATTACHMENTID
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)

caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: ATTACHMENTID
at org.hsqldb.error.Error.error(Unknown Source)

since the field and query in question is "attachmentId" I am not sure why there is no underscore. Alternately I am not sure if that is just because I added that field later, but my upgrade task seems to be ignored. I tried an atlas-clean to blow away any previous HSQL db files, but the error continues.

ao.find(MyObject.class,
"attachmentId = ? ",
attachment.getId());

@Preload
@Table("MYOBJECT")
public interface MyObject extends Entity{

	public long getAttachmentId();
	public void setAttachmentId(long id);

5 answers

Hmm, as I suspected the column generated by AO is using the underscore

CREATE TABLE AO_DF89C4_MYOBJECT (\u000a    ATTACHMENT_ID BIGINT DEFAULT 0,.........

so I need to figure out wjhy the query does not translate the same.

Yep, inserting underscores on camelCase boundaries is needed, https://developer.atlassian.com/display/AO/Column+names

It wont, _you_ have interpret the fields and map accordingly, i.e. "attachmentId = ? " ==> "ATTACHMENT_ID = ? "

Not sure I follow Andy.. I understand the convention, and would expext the column to have underscores. The problem is that when running the query, the query generated is not using the underscores.

I guess my concerns is the inconsitency, as these queries work just fine using AO's ActiveObjectTest against hsqldb as instructed here? https://developer.atlassian.com/display/AO/Getting+Started+with+Active+Objects#GettingStartedwithActiveObjects-Step12.TesttheTodoservice

And my understanding based on the examples from the author of AO doesn't use the underscore, as pointed in the document you linked to that should be handled by the FieldNameConverter

http://activeobjects.java.net/0.8.2/example.html

You can also see this a bit in the internals of the Query which converts the string to SQL using the field converter.

http://activeobjects.java.net/0.8.2/api/net/java/ao/Query.html#toSQL(java.lang.Class, net.java.ao.DatabaseProvider, net.java.ao.schema.TableNameConverter, net.java.ao.schema.FieldNameConverter, boolean)

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

396 views 5 10
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you