My situation is close to this question. I use patrodyne/hisrc-hyperjaxb maven plugin to generate entity classes with JPA annotions from xsd schema along with krasa-jaxb-tools plugin, which add validation annotaions.
There are some elements with type="xs:double" in my xsd scheme and after classes generation there are some Double fields which annotated @Column like this:
@Column(name = "SOURCE_RATIO", precision = 20, scale = 10)
public Double getSourceRatio() {
return sourceRatio;
}
Then I generate Spring Data repositories with cmeza20/spring-data-generator and use Spring Data REST dependency.
Besides of all, I want to auto-create my database scheme, so I put that property in my application.properties file:
spring.jpa.hibernate.ddl-auto=create
And when I run my application I get "java.lang.IllegalArgumentException: scale has no meaning for floating point numbers". How can I configurate @Column annotation to exclude precision and scale for Double java type?
I think the plugin have no any options to configure this (maybe Mr.O'Sullivan, plugin developer, can comment on that). But maybe "binding.xjc" may help with this problem. I don't have much experience with setting up the bindings file, please help me.
Try adding a HyperJAXB customization for
default-single-propertyto your XJC binding file, something like this:bindings.xjb
Indeed, you identified a bug in the HypeJAXB plugin. The plugin unmarshals its own DefaultCustomizations.xml to configure a
Persistenceobject which it uses to customize the generated classes. If you scroll the XML to find the entry for "3.2.5 xsd:double" you will see the origin of theprecisionandscalebug. This entry refers to Section 3.2.5 of XML Schema Part 2: Datatypes Second Edition (2004). That section shows that theprecisionandscalefacets are not defined for double (or float).Thank you for bringing this to my attention. I'll review and correct
DefaultCustomizations.xmlfor the next release. If you add an issue for this you can keep track of the progress (and remind me to do the review!).-- Rick