I have a class that contains a XMLGregorianCalendar
property, which is not a basic type supported by hibernate. The User Guide tells me an AttributeConverter
is a solution. However I found it has to be implemented with annotation @Converter
and I got this:
The property I need to handle is:
So I try to use hibernate mapping file, but I find no converter tags in it. How could I solve this problem?
you can add it to your entity mapping as described in this tutorial ( http://www.thoughts-on-java.org/how-to-use-jpa-type-converter-to/ )
<entity-mappings version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd">
<entity class="x.y.Entity">
<convert converter="x.y.CryptoConverter" attribute-name="yourField"/>
</entity>
</entity-mappings>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.