<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:06 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-358] Enums are not serialized without transformation</title>
                <link>https://jira.mongodb.org/browse/JAVA-358</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Enums cannot be serialized without transforming them.&lt;/p&gt;

&lt;p&gt;I propose, that all java enums are serialized (and deserialized) using the name() method (or valueOf() method).&lt;/p&gt;

&lt;p&gt;Example (using QueryDSL):&lt;/p&gt;

&lt;p&gt;@Entity&lt;br/&gt;
public enum Type {&lt;br/&gt;
	TYPE1, TYPE2&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;public class MyObject {&lt;/p&gt;

&lt;p&gt;	protected Type type;&lt;/p&gt;

&lt;p&gt;	public Type getType() {&lt;br/&gt;
	}&lt;/p&gt;

&lt;p&gt;	public void setType(Type type) &lt;/p&gt;
{
		this.type = type;
	}

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Usage:&lt;/p&gt;

&lt;p&gt;QMyObject.myObject.type.eq(Type.TYPE1); // ends in:&lt;/p&gt;

&lt;p&gt;java.lang.IllegalArgumentException: can&apos;t serialize class Type&lt;br/&gt;
	at org.bson.BSONEncoder._putObjectField(BSONEncoder.java:213)&lt;br/&gt;
	at org.bson.BSONEncoder.putObject(BSONEncoder.java:123)&lt;br/&gt;
	at org.bson.BSONEncoder._putObjectField(BSONEncoder.java:173)&lt;br/&gt;
	at org.bson.BSONEncoder.putObject(BSONEncoder.java:123)&lt;br/&gt;
	at org.bson.BSONEncoder.putObject(BSONEncoder.java:69)&lt;br/&gt;
	at com.mongodb.OutMessage.putObject(OutMessage.java:189)&lt;br/&gt;
	at com.mongodb.OutMessage._appendQuery(OutMessage.java:62)&lt;br/&gt;
	at com.mongodb.OutMessage.query(OutMessage.java:39)&lt;br/&gt;
	at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:293)&lt;br/&gt;
	at com.mongodb.DB.command(DB.java:152)&lt;br/&gt;
	at com.mongodb.DBCollection.getCount(DBCollection.java:760)&lt;br/&gt;
	at com.mongodb.DBCollection.getCount(DBCollection.java:731)&lt;br/&gt;
	at com.mongodb.DBCollection.count(DBCollection.java:697)&lt;br/&gt;
	at com.mysema.query.mongodb.MongodbQuery.count(MongodbQuery.java:184)&lt;br/&gt;
	at org.springframework.data.document.mongodb.repository.QueryDslMongoRepository.count(QueryDslMongoRepository.java:151)&lt;br/&gt;
	at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)&lt;br/&gt;
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&lt;br/&gt;
	at java.lang.reflect.Method.invoke(Method.java:616)&lt;br/&gt;
	at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:356)&lt;br/&gt;
	at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke(RepositoryFactorySupport.java:337)&lt;br/&gt;
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)&lt;br/&gt;
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)&lt;br/&gt;
	at $Proxy18.count(Unknown Source)&lt;/p&gt;</description>
                <environment></environment>
        <key id="17589">JAVA-358</key>
            <summary>Enums are not serialized without transformation</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="3">Duplicate</resolution>
                                        <assignee username="antoine">Antoine Girbal</assignee>
                                    <reporter username="robert.stiller">Robert Stiller</reporter>
                        <labels>
                    </labels>
                <created>Fri, 27 May 2011 09:17:43 +0000</created>
                <updated>Tue, 25 Jun 2013 16:51:18 +0000</updated>
                            <resolved>Fri, 27 May 2011 13:49:41 +0000</resolved>
                                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="34780" author="robert.stiller" created="Fri, 27 May 2011 09:29:27 +0000"  >&lt;p&gt;Same goes for java.util.Locale - it is one of the essential Types in Java!&lt;/p&gt;

&lt;p&gt;I propose the Serialization as follow:&lt;/p&gt;

&lt;p&gt;myLocale.toString();&lt;/p&gt;

&lt;p&gt;and the Deserialization:&lt;/p&gt;

&lt;p&gt;Copied from org.springframework.util.StringUtils.parseLocaleString(String):&lt;/p&gt;

&lt;p&gt;String[] parts = tokenizeToStringArray(localeString, &quot;_ &quot;, false, false);&lt;br/&gt;
String language = (parts.length &amp;gt; 0 ? parts&lt;span class=&quot;error&quot;&gt;&amp;#91;0&amp;#93;&lt;/span&gt; : &quot;&quot;);&lt;br/&gt;
String country = (parts.length &amp;gt; 1 ? parts&lt;span class=&quot;error&quot;&gt;&amp;#91;1&amp;#93;&lt;/span&gt; : &quot;&quot;);&lt;br/&gt;
String variant = &quot;&quot;;&lt;br/&gt;
if (parts.length &amp;gt;= 2) {&lt;br/&gt;
	// There is definitely a variant, and it is everything after the country&lt;br/&gt;
	// code sans the separator between the country code and the variant.&lt;br/&gt;
	int endIndexOfCountryCode = localeString.indexOf(country) + country.length();&lt;br/&gt;
	// Strip off any leading &apos;_&apos; and whitespace, what&apos;s left is the variant.&lt;br/&gt;
	variant = trimLeadingWhitespace(localeString.substring(endIndexOfCountryCode));&lt;br/&gt;
	if (variant.startsWith(&quot;_&quot;)) &lt;/p&gt;
{
		variant = trimLeadingCharacter(variant, &apos;_&apos;);
	}
&lt;p&gt;}&lt;br/&gt;
return (language.length() &amp;gt; 0 ? new Locale(language, country, variant) : null);&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="14598">JAVA-268</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="17597">JAVA-359</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhc2n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14756</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>