You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org> on 2008/03/28 17:13:39 UTC
[jira] Created: (CAY-1018) Enums fetched via SQLTemplate
Enums fetched via SQLTemplate
-----------------------------
Key: CAY-1018
URL: https://issues.apache.org/cayenne/browse/CAY-1018
Project: Cayenne
Issue Type: Bug
Components: Cayenne Core Library
Affects Versions: 3.0
Reporter: Andrus Adamchik
Assignee: Andrus Adamchik
Fix For: 3.0
This is not specifically enum related, but is is very easy to demonstrate the problem using enums... E.g.:
SQLTemplate q = new SQLTemplate(
EnumEntity.class,
"SELECT * FROM ENUM_ENTITY WHERE ENUM_ATTRIBUTE = 'one'");
q.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
EnumEntity e = (EnumEntity) DataObjectUtils.objectForQuery(context, q);
assertNotNull(e);
assertSame(Enum1.one, e.getEnumAttribute());
The last line throws ClassCastException as the enum value was stored as String. Essentially the problem is that SQLTemplate is created without a result set mapping, and doesn't bother to look at the root entity for type mapping...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
Re: [jira] Created: (CAY-1018) Enums fetched via SQLTemplate
Posted by Andrus Adamchik <an...@objectstyle.org>.
Sure. I am looking into CAY-1018 now. The fix is likely to be local to
the SQLTemplate backend code, so not directly related to the PK issue
(although in the future we may implement a generic solution that works
for both).
Andrus
On Mar 28, 2008, at 6:32 PM, Michael Gentry wrote:
> I tested doing queries using an Expression/SelectQuery and querying
> based upon enums, but never tried SQLTemplate. It seemed to work fine
> with the former, for whatever that is worth. I still need to look
> into the enum as PK issue, too. I haven't forgotten about that. I've
> just been a bit busy.
>
> Thanks,
>
> /dev/mrg
>
>
> On Fri, Mar 28, 2008 at 12:13 PM, Andrus Adamchik (JIRA)
> <de...@cayenne.apache.org> wrote:
>> Enums fetched via SQLTemplate
>> -----------------------------
>>
>> Key: CAY-1018
>> URL: https://issues.apache.org/cayenne/browse/
>> CAY-1018
>> Project: Cayenne
>> Issue Type: Bug
>> Components: Cayenne Core Library
>> Affects Versions: 3.0
>> Reporter: Andrus Adamchik
>> Assignee: Andrus Adamchik
>> Fix For: 3.0
>>
>>
>> This is not specifically enum related, but is is very easy to
>> demonstrate the problem using enums... E.g.:
>>
>> SQLTemplate q = new SQLTemplate(
>> EnumEntity.class,
>> "SELECT * FROM ENUM_ENTITY WHERE ENUM_ATTRIBUTE =
>> 'one'");
>>
>> q.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
>>
>> EnumEntity e = (EnumEntity)
>> DataObjectUtils.objectForQuery(context, q);
>> assertNotNull(e);
>> assertSame(Enum1.one, e.getEnumAttribute());
>>
>> The last line throws ClassCastException as the enum value was
>> stored as String. Essentially the problem is that SQLTemplate is
>> created without a result set mapping, and doesn't bother to look at
>> the root entity for type mapping...
>>
>> --
>> This message is automatically generated by JIRA.
>> -
>> You can reply to this email to add a comment to the issue online.
>>
>>
>
Re: [jira] Created: (CAY-1018) Enums fetched via SQLTemplate
Posted by Michael Gentry <bl...@gmail.com>.
I tested doing queries using an Expression/SelectQuery and querying
based upon enums, but never tried SQLTemplate. It seemed to work fine
with the former, for whatever that is worth. I still need to look
into the enum as PK issue, too. I haven't forgotten about that. I've
just been a bit busy.
Thanks,
/dev/mrg
On Fri, Mar 28, 2008 at 12:13 PM, Andrus Adamchik (JIRA)
<de...@cayenne.apache.org> wrote:
> Enums fetched via SQLTemplate
> -----------------------------
>
> Key: CAY-1018
> URL: https://issues.apache.org/cayenne/browse/CAY-1018
> Project: Cayenne
> Issue Type: Bug
> Components: Cayenne Core Library
> Affects Versions: 3.0
> Reporter: Andrus Adamchik
> Assignee: Andrus Adamchik
> Fix For: 3.0
>
>
> This is not specifically enum related, but is is very easy to demonstrate the problem using enums... E.g.:
>
> SQLTemplate q = new SQLTemplate(
> EnumEntity.class,
> "SELECT * FROM ENUM_ENTITY WHERE ENUM_ATTRIBUTE = 'one'");
> q.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
>
> EnumEntity e = (EnumEntity) DataObjectUtils.objectForQuery(context, q);
> assertNotNull(e);
> assertSame(Enum1.one, e.getEnumAttribute());
>
> The last line throws ClassCastException as the enum value was stored as String. Essentially the problem is that SQLTemplate is created without a result set mapping, and doesn't bother to look at the root entity for type mapping...
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>
[jira] Closed: (CAY-1018) Enums fetched via SQLTemplate
Posted by "Andrus Adamchik (JIRA)" <de...@cayenne.apache.org>.
[ https://issues.apache.org/cayenne/browse/CAY-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrus Adamchik closed CAY-1018.
--------------------------------
Resolution: Fixed
hopefully this fix and 'setColumnNamesCapitalization' will make SQLTeamplate a much more usable query in 3.0
> Enums fetched via SQLTemplate
> -----------------------------
>
> Key: CAY-1018
> URL: https://issues.apache.org/cayenne/browse/CAY-1018
> Project: Cayenne
> Issue Type: Bug
> Components: Cayenne Core Library
> Affects Versions: 3.0
> Reporter: Andrus Adamchik
> Assignee: Andrus Adamchik
> Fix For: 3.0
>
>
> This is not specifically enum related, but is is very easy to demonstrate the problem using enums... E.g.:
> SQLTemplate q = new SQLTemplate(
> EnumEntity.class,
> "SELECT * FROM ENUM_ENTITY WHERE ENUM_ATTRIBUTE = 'one'");
> q.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
> EnumEntity e = (EnumEntity) DataObjectUtils.objectForQuery(context, q);
> assertNotNull(e);
> assertSame(Enum1.one, e.getEnumAttribute());
> The last line throws ClassCastException as the enum value was stored as String. Essentially the problem is that SQLTemplate is created without a result set mapping, and doesn't bother to look at the root entity for type mapping...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.