Git Product home page Git Product logo

Comments (9)

jhiemer avatar jhiemer commented on August 19, 2024

Would be enough, to attach a StringToUUID Converter like this https://gist.github.com/2593664 ?

from spring-data-rest.

jbrisbin avatar jbrisbin commented on August 19, 2024

I haven't written up in the documentation yet how to do this, but the REST exporter will respect any ConversionService you have already defined before using a default one. So you can create an instance of DefaultConversionService and populate it with whatever Converters you need.

I'll probably go ahead and add some basic converters for things like UUID, Joda time, etc... things that are common to use in entities that people will likely need. Besides UUID, if there's a specific complex type you use in entities that can be handled by a Converter, let me know and we'll look at either including it by default or by including sample configuration to let you turn those things on or off as needed.

from spring-data-rest.

jhiemer avatar jhiemer commented on August 19, 2024

Hi Jonathan,
I took the example code you provided with spring-data-rest-webmvc. Then I changed the stuff like this: https://gist.github.com/2595158

But the error still exists and the number of converter do not get extend. Am I doing something wrong? I would really appreciate, if we could figure out what I am missing, so that I could keep playing around and extending the stuff over the weekend.

Thanks for your help!

from spring-data-rest.

jhiemer avatar jhiemer commented on August 19, 2024

Hi Jonathan,
I tried your latest build a few minutes ago an ran into the issue again. I added the following lines to my repositories-export.xml

<bean
    class="org.springframework.context.support.ConversionServiceFactoryBean">
    <property name="converters">
        <set>
            <bean
                class="org.springframework.data.rest.core.convert.StringToUUIDConverter" />
            <bean
                class="org.springframework.data.rest.core.convert.UUIDToStringConverter" />
        </set>
    </property>
</bean>

But the exception is still: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type java.util.UUID

As the rest of the repositories-export.xml is properly loaded, I think the converters do not get wired correctly.

Btw. I was searching for a small Unit-Test, but I couldn't find them. Do you maintain the unit-tests in separate private project?

Thanks for your patience with me. :-)

from spring-data-rest.

jbrisbin avatar jbrisbin commented on August 19, 2024

The previous snapshots used a different way to configure the exporter. The latest snapshot needs to be configured using the special servlet (which just ensures the right configuration class is used) an example of which I sent a link to in that previous email.

Using a different method to configure the exporter will result in the conversion service not being picked up by the exporter.

from spring-data-rest.

jhiemer avatar jhiemer commented on August 19, 2024

Hi Jon,
yes I configured my web.xml as you provided in the link. I browsed https://build.springsource.org/browse/SPRINGDATA-DATAWEB-58/commit and looked out for the changes.

But still, the converters do not get fired. Any other option?

from spring-data-rest.

jhiemer avatar jhiemer commented on August 19, 2024

Perhaps and additional piece of information. I set a breakpoint on line 1007 in RepositoryRestController.java to checking the number of converters in ConversionService. This is the output:

[ConversionService converters =
@org.springframework.format.annotation.DateTimeFormat java.lang.Long -> java.lang.String: org.springframework.format.support.DefaultFormattingConversionService$NoJodaDateTimeFormatAnnotationFormatterFactory@326907f7, @org.springframework.format.annotation.NumberFormat java.lang.Long -> java.lang.String: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
@org.springframework.format.annotation.DateTimeFormat java.util.Calendar -> java.lang.String: org.springframework.format.support.DefaultFormattingConversionService$NoJodaDateTimeFormatAnnotationFormatterFactory@326907f7
@org.springframework.format.annotation.DateTimeFormat java.util.Date -> java.lang.String: org.springframework.format.support.DefaultFormattingConversionService$NoJodaDateTimeFormatAnnotationFormatterFactory@326907f7
@org.springframework.format.annotation.NumberFormat java.lang.Double -> java.lang.String: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
@org.springframework.format.annotation.NumberFormat java.lang.Float -> java.lang.String: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
@org.springframework.format.annotation.NumberFormat java.lang.Integer -> java.lang.String: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
@org.springframework.format.annotation.NumberFormat java.lang.Short -> java.lang.String: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
@org.springframework.format.annotation.NumberFormat java.math.BigDecimal -> java.lang.String: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
@org.springframework.format.annotation.NumberFormat java.math.BigInteger -> java.lang.String: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
java.lang.Boolean -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter@24f2c136
java.lang.Character -> java.lang.Number : org.springframework.core.convert.support.CharacterToNumberFactory@7e909ea0
java.lang.Character -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter@54a67dda
java.lang.Enum -> java.lang.String : org.springframework.core.convert.support.EnumToStringConverter@68117ef6
java.lang.Number -> java.lang.Character : org.springframework.core.convert.support.NumberToCharacterConverter@25a6c601
java.lang.Number -> java.lang.Number : org.springframework.core.convert.support.NumberToNumberConverterFactory@71a95b43
java.lang.Number -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter@3f3bd723
java.lang.String -> @org.springframework.format.annotation.DateTimeFormat java.lang.Long: org.springframework.format.support.DefaultFormattingConversionService$NoJodaDateTimeFormatAnnotationFormatterFactory@326907f7, java.lang.String -> @org.springframework.format.annotation.NumberFormat java.lang.Long: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
java.lang.String -> @org.springframework.format.annotation.DateTimeFormat java.util.Calendar: org.springframework.format.support.DefaultFormattingConversionService$NoJodaDateTimeFormatAnnotationFormatterFactory@326907f7
java.lang.String -> @org.springframework.format.annotation.DateTimeFormat java.util.Date: org.springframework.format.support.DefaultFormattingConversionService$NoJodaDateTimeFormatAnnotationFormatterFactory@326907f7
java.lang.String -> @org.springframework.format.annotation.NumberFormat java.lang.Double: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
java.lang.String -> @org.springframework.format.annotation.NumberFormat java.lang.Float: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
java.lang.String -> @org.springframework.format.annotation.NumberFormat java.lang.Integer: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
java.lang.String -> @org.springframework.format.annotation.NumberFormat java.lang.Short: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
java.lang.String -> @org.springframework.format.annotation.NumberFormat java.math.BigDecimal: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
java.lang.String -> @org.springframework.format.annotation.NumberFormat java.math.BigInteger: org.springframework.format.number.NumberFormatAnnotationFormatterFactory@d8a02fc
java.lang.String -> java.lang.Boolean : org.springframework.core.convert.support.StringToBooleanConverter@46e2ea55
java.lang.String -> java.lang.Character : org.springframework.core.convert.support.StringToCharacterConverter@54d283bc
java.lang.String -> java.lang.Enum : org.springframework.core.convert.support.StringToEnumConverterFactory@6116dd53
java.lang.String -> java.lang.Number : org.springframework.core.convert.support.StringToNumberConverterFactory@5b8696ce
java.lang.String -> java.util.Locale : org.springframework.core.convert.support.StringToLocaleConverter@426f94ac
java.lang.String -> java.util.Properties : org.springframework.core.convert.support.StringToPropertiesConverter@7656e376
java.util.Locale -> java.lang.String : org.springframework.core.convert.support.ObjectToStringConverter@419f9a8a
java.util.Properties -> java.lang.String : org.springframework.core.convert.support.PropertiesToStringConverter@2b89ca47
org.springframework.core.convert.support.ArrayToArrayConverter@2c5612a8
org.springframework.core.convert.support.ArrayToCollectionConverter@147b7c85
org.springframework.core.convert.support.ArrayToObjectConverter@372c0a44
org.springframework.core.convert.support.ArrayToStringConverter@489e5b4a
org.springframework.core.convert.support.CollectionToArrayConverter@59027d30
org.springframework.core.convert.support.CollectionToCollectionConverter@304e4edb
org.springframework.core.convert.support.CollectionToObjectConverter@651b24a3
org.springframework.core.convert.support.CollectionToStringConverter@3d6ad32d
org.springframework.core.convert.support.FallbackObjectToStringConverter@5fc9f555
org.springframework.core.convert.support.IdToEntityConverter@605cc771, org.springframework.core.convert.support.ObjectToObjectConverter@6b29fd23
org.springframework.core.convert.support.MapToMapConverter@633f11a5
org.springframework.core.convert.support.ObjectToArrayConverter@11aa3bcc
org.springframework.core.convert.support.ObjectToCollectionConverter@4409d094
org.springframework.core.convert.support.StringToArrayConverter@48c6d725
org.springframework.core.convert.support.StringToCollectionConverter@241ca5f1
]

from spring-data-rest.

jbrisbin avatar jbrisbin commented on August 19, 2024

Looks like the MVC configuration class isn't seeing the user-defined ConversionService for some reason (@Autowired in RepositoryRestMvcConfiguration isn't seeing it). I'll put up another snapshot that looks for ConversionServices in a different way and see if that makes it easier.

from spring-data-rest.

jhiemer avatar jhiemer commented on August 19, 2024

Perfect, works!

from spring-data-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.