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

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2013

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

0 votes
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2013

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)

0 votes
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2013

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.

0 votes
Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2013

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

0 votes
Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2013

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

0 votes
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2013

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events