Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Enhancement using ENum literals in HQL queries...
[Teneo] Enhancement using ENum literals in HQL queries... [message #85317] Wed, 30 May 2007 15:06 Go to next message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Say you have an MLBTeam Enum with literals:
MLBTeam.YANKEES_LITERAL
MLBTeam.REDSOX_LITERAL

If Teneo's Enum UserType for Hibernate implemented
org.hibernate.usertype.EnhancedUserType
Then you could specify a query like:
"FROM Players WHERE player.team = MLBTeam.YANKEES_LITERAL"

Right now you have to use parameter substitution or construct the query
String above on the fly.
Perhaps there is some way to do this already that I don't know about.

Also, is there a way to using an integer column instead of a String column
when storing enumeration values in a DB column?
Thanks,
-mike
Re: [Teneo] Enhancement using ENum literals in HQL queries... [message #85385 is a reply to message #85317] Thu, 31 May 2007 06:58 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
To get integer columns you should use @Enumerated(ORDINAL).

I am not sure if MLBTeam.YANKEES_LITERAL is that different from using the string version of the enum
in the hql query. What is the benefit of using MLBTeam.YANKEES_LITERAL (as a string)?

gr. Martin

Michael Kanaley wrote:
> Say you have an MLBTeam Enum with literals:
> MLBTeam.YANKEES_LITERAL
> MLBTeam.REDSOX_LITERAL
>
> If Teneo's Enum UserType for Hibernate implemented
> org.hibernate.usertype.EnhancedUserType
> Then you could specify a query like:
> "FROM Players WHERE player.team = MLBTeam.YANKEES_LITERAL"
>
> Right now you have to use parameter substitution or construct the query
> String above on the fly.
> Perhaps there is some way to do this already that I don't know about.
>
> Also, is there a way to using an integer column instead of a String column
> when storing enumeration values in a DB column?
> Thanks,
> -mike
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Enhancement using ENum literals in HQL queries... [message #85426 is a reply to message #85385] Fri, 01 June 2007 11:01 Go to previous message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hi Martin,
The only reasons I see for this change are:
- Improve readability. This is questionable.
- Knowing that the property queried is an enum and not a String (if it is
SELECTed as an individual property and not an EObject). Might prevent a
ClassCastException when parsing the results.
- changing the Enum string constants in only one place. Happens rarely.

This is not an important enhancement (I haven't filed an enhancement) - I
thought I would mention it to see if there was positive response to it.
By all means get to the more important issues.
Thanks,
-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:f3lrnj$1bt$1@build.eclipse.org...
> Hi Mike,
> To get integer columns you should use @Enumerated(ORDINAL).
>
> I am not sure if MLBTeam.YANKEES_LITERAL is that different from using the
> string version of the enum in the hql query. What is the benefit of using
> MLBTeam.YANKEES_LITERAL (as a string)?
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Say you have an MLBTeam Enum with literals:
>> MLBTeam.YANKEES_LITERAL
>> MLBTeam.REDSOX_LITERAL
>>
>> If Teneo's Enum UserType for Hibernate implemented
>> org.hibernate.usertype.EnhancedUserType
>> Then you could specify a query like:
>> "FROM Players WHERE player.team = MLBTeam.YANKEES_LITERAL"
>>
>> Right now you have to use parameter substitution or construct the query
>> String above on the fly.
>> Perhaps there is some way to do this already that I don't know about.
>>
>> Also, is there a way to using an integer column instead of a String
>> column when storing enumeration values in a DB column?
>> Thanks,
>> -mike
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
Re: [Teneo] Enhancement using ENum literals in HQL queries... [message #606839 is a reply to message #85317] Thu, 31 May 2007 06:58 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mike,
To get integer columns you should use @Enumerated(ORDINAL).

I am not sure if MLBTeam.YANKEES_LITERAL is that different from using the string version of the enum
in the hql query. What is the benefit of using MLBTeam.YANKEES_LITERAL (as a string)?

gr. Martin

Michael Kanaley wrote:
> Say you have an MLBTeam Enum with literals:
> MLBTeam.YANKEES_LITERAL
> MLBTeam.REDSOX_LITERAL
>
> If Teneo's Enum UserType for Hibernate implemented
> org.hibernate.usertype.EnhancedUserType
> Then you could specify a query like:
> "FROM Players WHERE player.team = MLBTeam.YANKEES_LITERAL"
>
> Right now you have to use parameter substitution or construct the query
> String above on the fly.
> Perhaps there is some way to do this already that I don't know about.
>
> Also, is there a way to using an integer column instead of a String column
> when storing enumeration values in a DB column?
> Thanks,
> -mike
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Enhancement using ENum literals in HQL queries... [message #606845 is a reply to message #85385] Fri, 01 June 2007 11:01 Go to previous message
Michael Kanaley is currently offline Michael KanaleyFriend
Messages: 89
Registered: July 2009
Member
Hi Martin,
The only reasons I see for this change are:
- Improve readability. This is questionable.
- Knowing that the property queried is an enum and not a String (if it is
SELECTed as an individual property and not an EObject). Might prevent a
ClassCastException when parsing the results.
- changing the Enum string constants in only one place. Happens rarely.

This is not an important enhancement (I haven't filed an enhancement) - I
thought I would mention it to see if there was positive response to it.
By all means get to the more important issues.
Thanks,
-mike

"Martin Taal" <mtaal@elver.org> wrote in message
news:f3lrnj$1bt$1@build.eclipse.org...
> Hi Mike,
> To get integer columns you should use @Enumerated(ORDINAL).
>
> I am not sure if MLBTeam.YANKEES_LITERAL is that different from using the
> string version of the enum in the hql query. What is the benefit of using
> MLBTeam.YANKEES_LITERAL (as a string)?
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Say you have an MLBTeam Enum with literals:
>> MLBTeam.YANKEES_LITERAL
>> MLBTeam.REDSOX_LITERAL
>>
>> If Teneo's Enum UserType for Hibernate implemented
>> org.hibernate.usertype.EnhancedUserType
>> Then you could specify a query like:
>> "FROM Players WHERE player.team = MLBTeam.YANKEES_LITERAL"
>>
>> Right now you have to use parameter substitution or construct the query
>> String above on the fly.
>> Perhaps there is some way to do this already that I don't know about.
>>
>> Also, is there a way to using an integer column instead of a String
>> column when storing enumeration values in a DB column?
>> Thanks,
>> -mike
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
Previous Topic:[Teneo] Enhancement to provide a single base Exception class for all Teneo exceptions
Next Topic:Validation Exception with Teneo 0.7.5 (April 22) when moving to EMF 2.2.2
Goto Forum:
  


Current Time: Tue Apr 23 08:46:54 GMT 2024

Powered by FUDForum. Page generated in 0.03105 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top