You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by "Musall, Maik" <ma...@selbstdenker.ag> on 2017/05/04 14:05:05 UTC

ObjectSelect property return type

Hi,

I have this query:

	ColumnSelect<Object[]> select = ObjectSelect
		.query( PDCMarketingInfo.class )
		.where( someExpression )
		.columns( PDCMarketingInfo.CUSTOMER, Property.COUNT )
		.select( context );

where PDCMarketingInfo.CUSTOMER is a to-one relationship to another entity. Each row returned is an Object[] of length 2, with the second being a Long as expected, but the first is a byte[6]. What is this byte array? If I convert it to Integer, I can't make sense of the resulting number as well.

I know there is a newer API with .columnQuery() in the works, and although I would be interested if that is a solution to this, I'd still like to stay on 4.0M5 for production use.

Thanks
Maik


Re: ObjectSelect property return type

Posted by Andrus Adamchik <an...@objectstyle.org>.
I suspect the byte[] result is a Java-serialized form of the target ID (serialized Integer or Long??). Not sure why it does it in this case. Could be a bug. But as you have guessed, this API behavior is already different in M6. Per CAY-2255 it will return a full entity [1]. So probably unsafe to rely on the current behavior (broken or not) anyways. 

> I'd still like to stay on 4.0M5 for production use.

Understood. But note that M6 (likely to be renamed to B1) is quickly approaching. Could be a matter of weeks.

Andrus


[1] https://issues.apache.org/jira/browse/CAY-2255


> On May 4, 2017, at 5:05 PM, Musall, Maik <ma...@selbstdenker.ag> wrote:
> 
> Hi,
> 
> I have this query:
> 
> 	ColumnSelect<Object[]> select = ObjectSelect
> 		.query( PDCMarketingInfo.class )
> 		.where( someExpression )
> 		.columns( PDCMarketingInfo.CUSTOMER, Property.COUNT )
> 		.select( context );
> 
> where PDCMarketingInfo.CUSTOMER is a to-one relationship to another entity. Each row returned is an Object[] of length 2, with the second being a Long as expected, but the first is a byte[6]. What is this byte array? If I convert it to Integer, I can't make sense of the resulting number as well.
> 
> I know there is a newer API with .columnQuery() in the works, and although I would be interested if that is a solution to this, I'd still like to stay on 4.0M5 for production use.
> 
> Thanks
> Maik
>