You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by "Martin Taal (JIRA)" <ji...@apache.org> on 2005/04/18 12:47:45 UTC

[jira] Created: (OJB-24) Feature Request: enumerates and field conversions

Feature Request: enumerates and field conversions
-------------------------------------------------

         Key: OJB-24
         URL: http://issues.apache.org/jira/browse/OJB-24
     Project: OJB
        Type: New Feature
  Components: PB-API  
    Versions: 1.1 CVS    
    Reporter: Martin Taal
    Priority: Minor


Hi,
In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.

It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.

This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.

gr. Martin Taal


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Resolved: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Thomas Dudziak (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=all ]
     
Thomas Dudziak resolved OJB-24:
-------------------------------

     Resolution: Fixed
    Fix Version: 1.1 CVS

> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Assignee: Thomas Dudziak
>     Priority: Minor
>      Fix For: 1.1 CVS
>  Attachments: EMFEnumerationConverter.java
>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Commented: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Thomas Dudziak (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=comments#action_63115 ]
     
Thomas Dudziak commented on OJB-24:
-----------------------------------

I've added a new FieldConversionExt interface, please give it a try.

> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Assignee: Thomas Dudziak
>     Priority: Minor
>  Attachments: EMFEnumerationConverter.java
>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Commented: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Martin Taal (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=comments#action_63157 ]
     
Martin Taal commented on OJB-24:
--------------------------------

Yes, tried it and it works.

Thanks again.

gr. Martin

> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Assignee: Thomas Dudziak
>     Priority: Minor
>  Attachments: EMFEnumerationConverter.java
>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Commented: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Martin Taal (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=comments#action_63080 ]
     
Martin Taal commented on OJB-24:
--------------------------------

Actually I am looking at an emf enumerator (org.eclipse.emf.common.util.AbstractEnumerator) but the approach is very similar to commons-enum (never worked with that one though).
You are right that having a specific converter for each enum-subtype solves this issue (at least I think that is what you mean). 
However, what I think of is a generic field converter which detects what the required enum-type of the field is and then automatically converts the value from the db (and back). In this way I do not need a converter for each enum-subtype but can work with one generic converter (which I automatically add in the field-descriptor when I generate the repository.xml). However for this generic converter it has to know runtime what the fielddescriptor is.

Regarding code, what I currently do is to store the class name of the enum-type in the same db-field as the enum value (making the varchar a bit longer). In this way my generic converter reads the contents of the field, gets the class name from it and gets the enum object from the enum-class.


> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Priority: Minor

>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Updated: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Martin Taal (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=all ]

Martin Taal updated OJB-24:
---------------------------

    Attachment: EMFEnumerationConverter.java

Hi,
Here is the code I use now. It is just an example of my current approach (storing class name in the same field), maybe it helps a bit to clarify my nice-to-have request.
gr. Martin

> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Priority: Minor
>  Attachments: EMFEnumerationConverter.java
>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Commented: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Martin Taal (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=comments#action_63116 ]
     
Martin Taal commented on OJB-24:
--------------------------------

Yes that's what I mean and the ext interface would certainly work.

Thanks Thomas for your quick and positive replies!

gr. Martin

> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Assignee: Thomas Dudziak
>     Priority: Minor
>  Attachments: EMFEnumerationConverter.java
>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Commented: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Thomas Dudziak (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=comments#action_63113 ]
     
Thomas Dudziak commented on OJB-24:
-----------------------------------

Ok, I guess you'd like an extended FieldConversion interface that not only has the object (sql or java) but also the field descriptor (from there you can reach the class descriptor and so forth) ? Mhmm, this might be easily achievable via something like dependency injection, e.g. a setFieldDescriptor method at the field conversion class iff it implements a FieldConversionExt interface.
I'll have a look at it.

> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Priority: Minor
>  Attachments: EMFEnumerationConverter.java
>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Assigned: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Thomas Dudziak (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=all ]

Thomas Dudziak reassigned OJB-24:
---------------------------------

    Assign To: Thomas Dudziak

> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Assignee: Thomas Dudziak
>     Priority: Minor
>  Attachments: EMFEnumerationConverter.java
>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Closed: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Thomas Dudziak (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=all ]
     
Thomas Dudziak closed OJB-24:
-----------------------------


> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Assignee: Thomas Dudziak
>     Priority: Minor
>      Fix For: 1.1 CVS
>  Attachments: EMFEnumerationConverter.java
>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


[jira] Commented: (OJB-24) Feature Request: enumerates and field conversions

Posted by "Thomas Dudziak (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/OJB-24?page=comments#action_63071 ]
     
Thomas Dudziak commented on OJB-24:
-----------------------------------

Is this similar to commons-lang's Enum types ? I regularily use them with OJB where in general this involves one FieldConversion per Enum-subtype so the target type is clearly defined and the conversion does not need more info.
If not, could you add some sample code to show the usage scenario ?


> Feature Request: enumerates and field conversions
> -------------------------------------------------
>
>          Key: OJB-24
>          URL: http://issues.apache.org/jira/browse/OJB-24
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.1 CVS
>     Reporter: Martin Taal
>     Priority: Minor

>
> Hi,
> In my model I have enumerates which are represented as a java object in memory. An enumerate java object has an int and a String value. When the owner object is persisted I want to convert the enumerate object to either the int or the string and store it in a field. When the owner object is retrieved then the primitive type database field should be translated into the enumerate object.
> It seems logical to use fieldconversions to achieve this, however the field conversion interface only passes the value from the database and from this database value it can not be determined which Enumerate object should be created. This is so because different enumeratetypes can have the same value (with a different meaning). To identify which enumerate object should be created the fieldconversion interface could be extended so that also the field descriptor is passed.
> This is really just a very-low-priority-nice-to-have because there are many workarounds, e.g. store the enumerate class in the field also (etc.). But maybe somebody else also requires it or this has come-up earlier or maybe field conversions are looked at anyhow for a new larger release.
> gr. Martin Taal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org